DropDownCell Demo illustrates the usage of different dropdown controls as celltypes in grid cells. You will learn how to place Date Time pickers, user control, calculators into cells.
Essential Grid uses a control-sharing architecture. While a combo box may appear in many different cells (even with different drop-list content), there is usually only a single combo box that is moved around and populated as needed. This architecture allows Essential Grid to have many different controls without the overhead of creating multiple controls of the same type. You can even create your own custom control types. Other samples like Derived Cell Control Tutorial, Cell Buttons and Virtual Tree Grid have examples of derived cell controls.
Given below is an image of the sample.
Features:
DateTimePicker
In this sample GridStaticCellModel class is inherited. The derived cellmodel class handles the serialization requirements for the control and also creates the renderer class. The renderer class handles the UI requirements of the cell, like drawing, handling key actions, etc.
GridStaticCellRenderer is useful if you need support for embedding any custom .NET control inside a cell.
StyleInfo.CellType is set for the cells that need to have custom cell control.
this.gridControl1[4,2].CellType = "DateTimePicker"; this.gridControl1[4,2].CellValueType = typeof(DateTime); this.gridControl1[4,2].CellValue = DateTime.Now; this.gridControl1[4,2].Format = "MM/dd/yyyy hh:mm";
DropDownGrid Cells
It uses a custom cell, DropDownGridCellModel/DropDownGridCellRenderer that is derived from GridDropDownGridCellModel/GridDropDownGridCellRenderer to display a drop-down grid.
GridDropDownGridCellModel class receives an instance of GridControlBase class and displays it through GridDropDownGridCellRenderer class. For more information, refer to the DropDownGridCell.cs file in this sample.
The GridCellComboBoxButton object is created and assigned to DropDownButton in DropDownGridCellRenderer’s constructor.
DropDown Form and UserControl
It demonstrates the display of a model form using,
The Form.Show dialog box, which appears on a button click within the cell; this happens by deriving GridStaticCellModel or GridStaticCellRenderer classes.
Deriving GridDropDownCellModel or GridDropDownCellRenderer classes to drop a user control in a manner that handles the focus issues involved with pop-up windows.
The cell controls in both the above cases display a checked list box in the drop-down. The cell value lists the selected options as a comma delimited string. See the Derived Cell Control section in the Grid’s User Guide for more information on custom cell controls.
DropDown Calculator
This is done by creating custom cell model and cell renderer classes from GridStaticCellModel and GridStaticCellRenderer classes respectively.
In cell renderer, the drop-down container is added by initializing the drop-down part. A grid-combo-box cell button is created by clicking the cell renderer. This lets the container to be dropped down.