Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - Get Form Designer To Ignore Properties

Reply
 
Old 11-11-2008   #1 (permalink)
k.mellor


 
 

Get Form Designer To Ignore Properties

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

My System SpecsSystem Spec
Old 11-11-2008   #2 (permalink)
Fred


 
 

Re: Get Form Designer To Ignore Properties

in
news:3c9ac1eb-e2c5-4812-a981-c773ebaefe10@xxxxxx,
k.mellor@xxxxxx wrote :
Quote:

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

--
Fred
foleide@xxxxxx

My System SpecsSystem Spec
Old 11-11-2008   #3 (permalink)
eschneider


 
 

Re: Get Form Designer To Ignore Properties


Try this attribute:

using System.ComponentModel

[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]



<k.mellor@xxxxxx> wrote in message
news:3c9ac1eb-e2c5-4812-a981-c773ebaefe10@xxxxxx
Quote:

> 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

My System SpecsSystem Spec
Old 11-12-2008   #4 (permalink)
k.mellor


 
 

Re: Get Form Designer To Ignore Properties

Thank you both for your replies.

[DesignerSerializationVisibility
(DesignerSerializationVisibility.Hidden)]

works perfectly.

Kevin
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
How to access the designer class for a WPF form .NET General
Modifying OEM properties listed in system properties Vista installation & setup
designer Vista General
Expression Web Designer Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46