How to: Use a TemplateColumn for Showing and Editing Time Values
Important
This documentation topic describes legacy technology. We no longer develop new functionality for the GridControl and suggest that you use the new DataGridView control instead.
This example illustrates how to create a TemplateColumn for showing and editing time values. To implement this functionality, follow the steps below.
- Create a data object (TestData in this example) and populate it with the required time values to be shown in the TemplateColumn. Assign the generated time list to the GridControl.ItemsSource property.
Add a new TemplateColumn to the GridControl.Columns collection. In this example the following column parameters are used:
- GridColumn.UnboundType = UnboundColumnType.Object
TemplateColumn.DisplayTemplate = new DataTemplate(typeof(DisplayControl))
The DisplayControl class represents a label whose Text property is bound to the CellData.Value property using the IValueConverter object.
TemplateColumn.EditTemplate = new DataTemplate(typeof(EditControl))
The EditControl class represents the TimePicker control whose Time property is two-way bound to the CellData.Value property.
- Subscribe to the GridControl.CustomUnboundColumnData event and use its handler to set and get time data.