Persist custom list<string> property of datagridviewcolumn

355 views Asked by At

I have a WinForm application with a customized DataGridViewColumn with 1 added property, a simple List<string>. I can change it to whatever sort of collection will make it work, if needed. The problem I am having is that when I set the property in the Designer, it does not persist. When I click OK and then go back into it, it is blank again. I have done extensive research and tried everything I can find but it does this no matter what.

The latest try is below:

[TypeConverterAttribute(typeof(System.ComponentModel.ExpandableObjectConverter))]
public class MyCustomColumn : DataGridViewComboBoxColumn
{
    [Editor("System.Windows.Forms.Design.StringCollectionEditor,System.Design",
     "System.Drawing.Design.UITypeEditor, System.Drawing")]
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
    [Description("My custom property")]
    public List<string> MyListOfStrings {get;set;}

    public MyCustomColumn()
    {
        this.CellTemplate = new MyCustomCell();
        MyListOfStrings = new List<string>();
    }
}
0

There are 0 answers