tags:

views:

235

answers:

3

How do you stop the designer from auto generating code that sets the value for public properties on a user control?

A: 

you don't need to stop it from doing it
just put your own initialization in Form_Load() putting in values on the property windows will also override the default values that the designer generate with your own values.

paan
A: 

Add these attributes to the property in your control:

[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]

Will Dean
+3  A: 

Use the DesignerSerializationVisibilityAttribute on the properties that you want to hide from the designer serialization and set the parameter to Hidden.

[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public string Name
{
    get;
    set;
}
Erik Hellström