Reputation: 8003
I need to add a string property to a DataGridViewTextBoxColumn
: to do this I've created my custom column:
public class MhsDataGridViewTextBoxColumn : DataGridViewTextBoxColumn
{
public string TableName { get; set; }
public MhsDataGridViewTextBoxColumn()
{
this.CellTemplate = new DataGridViewTextBoxCell();
}
}
and in the columns editor appears correctly:
but if I press ok and save the column properties, the new property is not saved and each time I open the columns editor the TableName
property is blank..
is there a simple way to store the custom properties?
thanks
Upvotes: 2
Views: 273
Reputation: 81610
I believe you are required to override the Clone function in order for that to work:
public override object Clone() {
var column = base.Clone() as MhsDataGridViewTextBoxColumn;
if (column != null) {
column.TableName = this.TableName;
}
return column;
}
Upvotes: 6