When the DataGridView needs to create a new cell in the column the method DataGridViewTextBoxCell.Clone is called in order to duplicate the ’DataGridViewColumn.CellTemplate’. It’s perfectly logical.
You can override the Clone method, but you can’t call base.Clone() since it returns an object of the base class type and you can’t code a copy constructor because there is no copy constructor for DataGridViewTextBoxCell.
With a base copy constructor you could code a Clone method like this :
[C#]
public override object Clone()
{
return new MyDataGridViewEditingTextBoxCell(this);
}
With your overridden copy constructor you could code a Clone method like this :
public CustomDataGridViewTextBoxCell( CustomDataGridViewTextBoxCell cell)
: base( cell )
{
// Copy data of CustomDataGridViewTextBoxCell
this.Flag = new Flag( cell.Flag );
this.Data = cell.Data.Clone() as Data;
// ...
}
Share with