Gridcontrol cell time
Hello,
I need to have a column cells to manually insert time.
I've tried the code below but can't block context menu and can't show some type dropdown clock.
gridControl1[1, 1].CellType = "DateTimePicker";
gridControl1[1, 1].CellValueType = typeof(DateTime);
gridControl1[1, 1].CellValue = DateTime.Now;
gridControl1[1, 1].Format = "HH:mm";
I've tried also:
gridControl1[1, 3].CellType = "MaskEdit";
gridControl1[1, 3].CellValueType = typeof(DateTime);
gridControl1[1, 3].Format = "HH:MM";
gridControl1[1, 3].MaskEdit.Mask = "99:99";
In this I can't disable context menu and always show 10:12 after I put some other time.
What is the best way to insert manually time? Without context menu? With dropdown clock?
Thanks
Based on the information provided, we understand that you need to define the cell type as `DateTimePicker` with the dropdown clock. However, the `GridControl` doesn't directly support the `DateTimePicker` cell type. You will need to register custom cell types for the `GridControl`. We have relevant user guide documentation available. Please refer to the link below and let us know if it meets your requirements:
Hi Malini
In the attached image is an context menu and a dropdown example.
How can I disable the context menu?
Is it possible to show some kind of clock in the dropdown option instead of a calendar?
Thanks
Attachment: Grid_88a4340b.rar
Hi Dinis
Ferreira,
|
Query |
Update |
|
|
How can I disable the context menu? |
Based on the information provided, we understand that you would like to disable the context menu for the `DateTimePicker`. This can be achieved by defining a custom cell renderer for the `DateTimeCell` and creating a custom cell model. Within this setup, you can disable the context menu for the `DateTimePicker` cell.
To assist you further, we have prepared a sample demonstrating this approach.Please review the sample and the accompanying code snippet, and let us know if it meets your requirements.
Code Snippet:
If we have misunderstood your request or if your requirements differ, please provide additional details. This will help us better understand the issue and offer a more suitable solution.
Thank you for your cooperation and understanding. |
|
|
Is it possible to show some kind of clock in the dropdown option instead of a calendar? |
We are currently analyzing the scenario you reported and require additional time to validate it. We will provide an update on or before December 19, 2024.
We appreciate your patience in the meantime. |
Regards,
Malini Selvarasu
Attachment: GridControl_Demo_c5655a99.zip
Hi Malini
First part works fine, thanks.
Based on the information provided, we understand that you wish to replace the DropDown Calendar with a DropDown Clock. The `DateTimePickerAdv` control has been used in the cell; however, this functionality is not supported in the `DateTimePickerAdv` control, so we cannot add a DropDown Clock.
gridControl1.CellModels.Add("CustomDateTimePicker", new CustomDateTimePickerModel(gridControl1.Model)); public class CustomDateTimePickerModel : GridDropDownCellModel { public CustomDateTimePickerModel(GridModel grid) : base(grid) { } public override GridCellRendererBase CreateRenderer(GridControlBase control) { return new CustomClockCellRenderer(control, this); } } public class CustomClockCellRenderer : DateTimeCellRenderer { private DateTimePickerAdv DateTimePickerAdv; public CustomClockCellRenderer(GridControlBase grid, GridCellModelBase cellModel) : base(grid, cellModel) { FieldInfo fieldInfo = typeof(DateTimeCellRenderer).GetField("dateTimePicker", BindingFlags.NonPublic | BindingFlags.Instance); DateTimePickerAdv = (DateTimePickerAdv)fieldInfo.GetValue(this); this.DateTimePickerAdv.ContextMenu = new ContextMenu(new MenuItem[] { }); this.DateTimePickerAdv.Format = DateTimePickerFormat.Time; this.DateTimePickerAdv.ShowUpDown = true; } } |
Thank you for your understanding.
Malini Selvarasu
Hi Malini,
This also works, thank you.
We are glad to hear that your requirement has been fulfilled. Hence, we are closing this forum. Please feel free to reach out to us if you need further assistance. We are always happy to help.
- 7 Replies
- 2 Participants
-
DF Dinis Ferreira
- Dec 10, 2024 04:55 PM UTC
- Dec 24, 2024 09:14 AM UTC