The Row class as well as all the classes that derive from the Row class can be derived from to create custom row classes. To create a row class that contains cells, it is necessary to derive from the CellRow class, or one of its derived classes, rather than directly from the Row class. To create a row class that does not contain cells, then you can derive directly from the Row class or any other of the row classes that do not contain cells.
When creating a class that derives from the Row class or one of its derived classes, the following minimum functions must be implemented:
A public constructor with no parameters.
A protected constructor that receives an instance of the derived class as a parameter.
An override of the CreateInstance method.
When deriving directly from the CellRow class, an override for the CellType property must also be added.
When creating a class that derives from the CellRow class or one of its derived classes, the following minimum functionalities need to be implemented:
A public constructor with no parameters.
A protected constructor that receives an instance of the derived class as a parameter.
An override of the CreateCell method.
An override of the CreateInstance method.
The newly created classes can then be used seamlessly within Xceed Grid for WinForms. For example, because the row class in the demonstration below derives from the DataRow class, it can be used as a template to create the data rows that will populate the grid. This is done by assigning a new instance of the class to the GridControl's DataRowTemplate property.
VB.NET | Copy Code |
---|---|
GridControl1.DataRowTemplate = New ImageRow() |
C# | Copy Code |
---|---|
gridControl1.DataRowTemplate = new ImageRow(); |
The GridElement class implements the IComponent interface which derives from the IDisposable interface. This allows each grid element to be a component in the Grid Designer and thus individually selectable. It is not necessary however to call the Dispose method on the GridElement class nor on any class that derives from the GridElement class.
When creating a class that derives from GridElement (or any of its derived classes), code should not be placed within the IDisposable.Dispose method since Dispose will not be called.
The following example demonstrates the minimum implementation required for a class that derives from the DataRow class. A working version of this class can be found in the in the Puzzle sample.
VB.NET | Copy Code |
---|---|
|
C# | Copy Code |
---|---|
|
Do you want to use your Row class in the Grid Designer? A public constructor that takes a RowSelector object as a parameter must be added to your class.