DropDownCell Demo illustrates the usage of different controls as celltypes in grid cells. You will learn how to place chart controls, pictureboxes, html and Gridcontrols 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:
ChartCell
To have a chart cell, set the CellType property to "ChartCell"
style.CellType = "ChartCell";
Built-in custom style properties can be associated with chart cells
Interactive Features:
You can interact with the chart cell instantaneously by changing chart data at run-time
You can navigate between different cells using the Arrow keys or using Mouse
Dynamically change the settings in the property grid and monitor those changes applied to the current cell
GridInCell
GridGenericControlCellModel class is inherited. The model class handles the serialization requirements for the control and creates the renderer class which handles the UI requirements of the cell, such as drawing it, handling mouse actions, etc. The GridGenericControlCellRenderer class is useful if you need support for embedding any custom .NET control inside a cell.
A custom cell type is registered by adding an instance of the GridCellModelBase derived class to the grid CellModels collection and by passing a string that is used as the Style.CellType value for this custom cell type.
This special cell type requires you to create instances for each grid that are used in the cells with the CellEmbeddedGrid class and by passing the parent grid in that constructor.
GridControl grid; this.gridControl1[2,2].CellType = "GridinCell"; this.gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(2, 2, 6, 4)); grid = new CellEmbeddedGrid(this.gridControl1); this.gridControl1[2,2].Control = grid;
With that instance, the grid properties can be set on each grid used in the cells.
grid.RowCount = 5; grid.ColCount = 5; grid[1,1].Text = "this is a 5x5 grid"; grid.ThemesEnabled = true;
XHTML Cell
Custom cell types require you to derive two classes: GridCellModelBase and GridCellRendererBase.
The cellmodel class handles any serialization if required and also recreates the renderer class that is associated with the cell type.
The cellrenderer class manages the UI aspects of the cell type.
PictureBox
CellType property should be set to "Calendar" for the cells that need to have custom cell control.
This sample creates a Month Calendar control for every cell. CalendarCellRenderer will then manage that MonthCalendar control and displays it inside the cell.
Additionally, ResizingRows and ResizingColumns events are handled in order to maintain the least minimization of the size of the control. By using SizeIndicatorBorder property on the instances of GridResizingRowsEventArgs and GridResizingColumnsEventArgs, the resizing indicator can be changed. This has been illustrated in the images below: