A
Armin Zingler
Hi,
as I don't get an answer in vstudio.development within weeks, I try it here:
I'm referring to Designer Serialization:
http://msdn.microsoft.com/en-us/library/ms171834.aspx
I derived a class from DataGridView. In the class' ctor, I add two columns. After compilation
and putting an instance of my control from the toolbox onto a form using the designer, the
designer creates the code that adds the columns at runtime (mydgv.columns.add inside
InitializeComponent).
The problem is: If I run the application, the control now has 4 columns because the columns
are added in my ctor and additionally by the designer generated code.
So my question is: How can I tell the designer to exclude the Columns property from
serialization? In other cases, I do know how to handle this, either by attaching the
DefaultValue attribute or the DesignerSerializationVisibility attribute.
First, the DefaultValue attribute is not appropriate for this type of properties.
Second, to be able to attach the DesignerSerializationVisibility to the Columns property,
I had to shadow the base class property:
<DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
Shadows ReadOnly Property Columns() As DataGridViewColumnCollection
Get
Return MyBase.Columns
End Get
End Property
Still this does not prevent the designer from serializing the property.
Did I miss something? How to handle this case?
as I don't get an answer in vstudio.development within weeks, I try it here:
I'm referring to Designer Serialization:
http://msdn.microsoft.com/en-us/library/ms171834.aspx
I derived a class from DataGridView. In the class' ctor, I add two columns. After compilation
and putting an instance of my control from the toolbox onto a form using the designer, the
designer creates the code that adds the columns at runtime (mydgv.columns.add inside
InitializeComponent).
The problem is: If I run the application, the control now has 4 columns because the columns
are added in my ctor and additionally by the designer generated code.
So my question is: How can I tell the designer to exclude the Columns property from
serialization? In other cases, I do know how to handle this, either by attaching the
DefaultValue attribute or the DesignerSerializationVisibility attribute.
First, the DefaultValue attribute is not appropriate for this type of properties.
Second, to be able to attach the DesignerSerializationVisibility to the Columns property,
I had to shadow the base class property:
<DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
Shadows ReadOnly Property Columns() As DataGridViewColumnCollection
Get
Return MyBase.Columns
End Get
End Property
Still this does not prevent the designer from serializing the property.
Did I miss something? How to handle this case?