Hi Mehdi58,
We need to override the Clone method of DataGridViewColumn to support copying values of the custom properties. This is the code snippet:
public class MyDataGridViewColumn : DataGridViewColumn
{
//The custom property.
private bool _showValue;
[DefaultValue(false)]
public bool ShowValue
{
get { return _showValue; }
set { _showValue = value; }
}
//Override this method to set the custom properties.
public override object Clone()
{
MyDataGridViewColumn col = base.Clone() as MyDataGridViewColumn;
col.ShowValue = ShowValue;
return col;
}
}
Let me know if this helps.
Aland Li
Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.