| MultiRow Windows Forms > Developer's Guide > Using MultiRow > Cell Types > User-Defined Cell |
The user-defined cell is a cell type created from the base cell or other combination of cell types as the base.

The user-defined cell is created as an inherited class of an existing cell type class. Depending upon the required features, you can select any cell type as the base. For example, see the following scenarios:
![]() |
In the case of adding a new property into the class inherited from a cell or built-in cell type, you need to override the Clone method and copy the value of the new property while duplicating. For more details, refer to Add Custom Property mentioned later. |
The user-defined cell can be implemented through code regardless of the type of project (application, class library). You can define a cell and then register it in the toolbox, all in a project that is currently being debugged (the same way you use a user control in a Windows form).
The following steps explain how to create a user-defined cell and place it in the template designer.
Imports System.Drawing
Imports System.Windows.Forms
Imports GrapeCity.Win.MultiRow
Public Class MyTextBoxCell
Inherits TextBoxCell
Public Sub New()
Me.Style.BackColor = Color.Azure
End Sub
End Class
|
using System.Drawing;
using System.Windows.Forms;
using GrapeCity.Win.MultiRow;
public class MyTextBoxCell : TextBoxCell
{
public MyTextBoxCell()
{
base.Style.BackColor = Color.Azure;
}
}
|
Now that the user-defined cell has been created, you can drag and drop it from the ToolBox to the Template and you can use it the same way as a built-in cell type.
Cells added to the GcMultiRow control become clones of the cell instances (GcMultiRow.Template.Row.Cells property), at runtime. So if you have created a user-defined cell and are implementing the Custom property, you need to create a duplicate of the property value in the Clone method.
The following example creates a custom property.
Public Class MyTextBoxCell
Inherits TextBoxCell
Private _editingBackColor As Color
Property EditingBackColor() As Color
Get
Return _editingBackColor
End Get
Set(ByVal value As Color)
_editingBackColor = value
End Set
End Property
End Class
|
public class MyTextBoxCell : TextBoxCell
{
private Color _editingBackColor;
public Color EditingBackColor
{
get { return _editingBackColor; }
set { _editingBackColor = value; }
}
}
|
The code for the Clone method is as follows.
Public Class MyTextBoxCell
Inherits TextBoxCell
Public Overrides Function Clone() As Object
Dim myTextBoxCell As MyTextBoxCell = DirectCast(MyBase.Clone, MyTextBoxCell)
myTextBoxCell._editingBackColor = Me.EditingBackColor
Return myTextBoxCell
End Function
End Class
|
public class MyTextBoxCell : TextBoxCell
{
public override object Clone()
{
MyTextBoxCell myTextBoxCell = base.Clone() as MyTextBoxCell;
myTextBoxCell._editingBackColor = this.EditingBackColor;
return myTextBoxCell;
}
}
|
For more information, see the following topic: