I want to show a specific date time picker control on a particular cell in Telerik RadGridView in C# Windows form. For this I need to know the co-ordinates of that particular cell relative to that form. I don't want to set the full column to DateTimePicker since the datatype won't be fixed for all the rows of that particular column. How can I retrieve the current cell co-ordinates so that I can show a separate DataTimePicker control at that position?
RadGridView uses editors for its cells. To achieve your scenario you should create a custom editor and assign this editor in the EditorRequired event for the particular cell. Here is an article from the Telerik UI for WinForms documentation which says how you can create and use custom editor: http://www.telerik.com/help/winforms/gridview-editors-using-custom-editors.html
Related
On the datagridview cellclick event i have ploted two controls,one is a combobox that displays weekdays and
other is a datetimepicker control.
By default both the controls are left aligned hence i am not able to view the date inside datetimepicker control.
Hence i changed the property of datetimepicker control to:
dtPickerForFolder.DropDownAlign = LeftRightAlignment.Right;
But the problem is if i set this property i am able to see the date inside datetimepicker control in this format:
PM02:57:12.That is in a reverse format.
How to solve this issue?
I am not very good in WinForms, but probably you should add two controls in some container. In WPF it could be StackPanel or something. I think WinForms has something similar
In the .Net 4.0 WPF Datagrid, the edit mode of a DataGridComboBoxColumn pops up the ComboBox drop-down in a size that is not dependent on the size of the cell containing the data.
I am building a template for a cell that is somewhat like a combobox, but has features like multi-select, other controls as collaborating neighbors, etc. My editor is working nicely, except for one issue.
I've been trying to figure out how to make the editor appear in front of the DataGridCell that is being edited, and not limited to the current size of that cell, so that the control can be large enough to present content and behaviors nicely to the user. This is similar to what the drop-down of the combobox cell does in WPF data grid.
Can anyone tell me how to do that?
Thanks in advance...
ComboBoxes use Popups, you could put your control in one (presumably only when editing -> Put one in the CellEditingTemplate).
I'm trying to create a DataGridView cell class which hosts a control (all the time, not just while editing). So far, my approach has been to add the control to the grid and try to synchronise its position with that of the cell.
Would it be possible instead to keep the cell offscreen, route mouse and keyboard events to it, and paint it onto the cell?
UPDATE: By 'offscreen', I don't mean that it should be added to another control such that it isn't displayed; I mean that it should never be added to another control at all.
You can create a control without adding it to the form, then using it as the Cell editor whenever you need to. Usually with grids, when you click on a cell to edit it, it's going to either create a new control and put it in the right place, or it's going to use an existing control. You can make this process a lot easier by creating your own custom cell / column types. See this MSDN page: http://msdn.microsoft.com/en-us/library/7fb61s43.aspx.
Most grids (including DataGridView and 3rd Party Grids) have a facility for adding custom cells.
I have a datepicker control that I am using to set a date field in a gridview control, my datepicker shows a date and a button to display a calendar you can use to pick a date. This works great on its own but when I add this to a gridview the calendar pops up and the columns and rows cover up parts of the calendar. Setting the ZIndex for the calendar doesn't help because the other rows are on different panels? How can I get around this? I tried raising the ZIndex of the VisualParent but no luck.
Update, the gridview is very standard, 4 columns one of which is a date column, the datatemplate for that column creates a datepicker which initially looks like a text box and a button, the button is placed on a canvas panel and when clicked a calendar is added to the canvas. The canvas is the only panel that allows its children to stretch over its own boundaries so the button is 10 x 10 or so and the calendar is 200 x 200. When the calendar pops up it normally just covers up adjacent fields but when placed on a gridview each cell of the gridview that is "after" the datepicker covers up the calendar. I'm supposing I need to raise the zindex of my cell but I can't find a way to do this?
Could you provide more info about gridview and datepicker? Especially are they your custom controls or do they belong to any open source or commercial libraries or separate?
You also mentioned that DataTemplate has Canvas as a panel. Even though a Canvas can contain large elements, it does not necessarily show all of its children. This may or may not relate to your problem, though.
P.S. Sorry I had to post this as an answer. My reputation does not allow me to comment?
Wow, this should be done using a popup or an expander.
Is there any way to embed a widget in a data-bound DataGridViewCell when it is not in editing mode?
For example, we are wanting to display an existing calendar widget in a cell. That cell contains a comma separated list of dates. We want to show the calendar instead of the text.
We could create a custom cell and override the Draw method so that it draws the calendar in the cell, but that would not handle the mouse-over tool-tip that we already have in the existing calendar widget.
[Update]
I tried TcKs's suggestion, but was not able to create a working solution. See the comments on that answer.
You should derive your own type from DataGridViewColumn (e.g. a DataGridViewCalendarColumn) and return a DataGridViewCalendarCell (that you have to create yourself, too) as the CellTemplate.
A detailed description can be found in the MSDN article Build a Custom RadioButton Cell and Column for the DataGridView Control
You can instead of drawing calendar, take a calendar control, set them the grid as parent and set them same bounds ( left, top, width, height ) as cell has.