Get Form Designer To Ignore Properties

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
 
F

Fred

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.
 
E

eschneider

Try this attribute:

using System.ComponentModel

[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
 
K

k.mellor

Thank you both for your replies.

[DesignerSerializationVisibility
(DesignerSerializationVisibility.Hidden)]

works perfectly.

Kevin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top