Get Form Designer To Ignore Properties

  • Thread starter Thread starter k.mellor
  • Start date Start date
K

k.mellor

Hi all,

I am using Visual Studio 2005.

I have a User Control with the following property

[Browsable (false) ]
public String MyProperty
{
get { return this.my_property_var; }
set { this.my_property_var = value; }
}


When I place my User Control on a form I cannot see the property in
the Property Browser (good), but default code does get generated in
InitializeConponent

......////....
MyControl.MyProperty = "";
......////....

How can I prevent this?

I really ask as my properties in my live code are DateTime properties
and their default values get set to the day/time the form was designed
and ideally I do no want to set them to DateTime.Now in the Load
method or similar.

Thanks in advance.

Kevin
 
in
Hi all,

I am using Visual Studio 2005.

I have a User Control with the following property

[Browsable (false) ]
public String MyProperty
{
get { return this.my_property_var; }
set { this.my_property_var = value; }
}


When I place my User Control on a form I cannot see the property in
the Property Browser (good), but default code does get generated in
InitializeConponent

.....////....
MyControl.MyProperty = "";
.....////....

How can I prevent this?

Try to use the DefaultValue Attribute. I think it will prevent the code
to be generated if I remember well.
 
Try this attribute:

using System.ComponentModel

[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
 
Thank you both for your replies.

[DesignerSerializationVisibility
(DesignerSerializationVisibility.Hidden)]

works perfectly.

Kevin
 
Back
Top