PC Review


Reply
Thread Tools Rate Thread

Designer throws Excepion : [System.ComponentModel.Browsable(false)] seems not to work as expected.

 
 
Sagaert Johan
Guest
Posts: n/a
 
      12th Jan 2007
hi

In a componenet class i have a property with the attribute
[System.ComponentModel.Browsable(false)]

public int Vsetting

{

set{....}

get{...}

}



When i use the component on a form, the property is not visible in de
peoperties window of the designer (thats ok)

But still the IDE seems to put a line in the form.designer.cs

Vsetting=10;

How can i avoid the IDE inserting that ?



Johan




 
Reply With Quote
 
 
 
 
Stoitcho Goutsev \(100\)
Guest
Posts: n/a
 
      12th Jan 2007
Sagaert,

The fact that the property is not visible doesn't meen it is not going to be
serialized in the code.
There are couple of ways you can prevent this.

1. Specify propertie's default value. The designer won't serialize
properties, which has been set to their default values. You can do that
using DefaultValueAttribute attribute or for more complex scenarios you can
provide ShouldSerializeXXXX method

2. Using DesignerSerializationVisibilityAttribute. If you add
DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)
to your property its value won't be serialized into the code regardless of
its value.


--
HTH
Stoitcho Goutsev (100)

"Sagaert Johan" <(E-Mail Removed)> wrote in message
news:u%(E-Mail Removed)...
> hi
>
> In a componenet class i have a property with the attribute
> [System.ComponentModel.Browsable(false)]
>
> public int Vsetting
>
> {
>
> set{....}
>
> get{...}
>
> }
>
>
>
> When i use the component on a form, the property is not visible in de
> peoperties window of the designer (thats ok)
>
> But still the IDE seems to put a line in the form.designer.cs
>
> Vsetting=10;
>
> How can i avoid the IDE inserting that ?
>
>
>
> Johan
>
>
>
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ComVisible(false) doesn't work as expected Tony Johansson Microsoft C# .NET 5 29th Apr 2010 04:20 PM
The type or namespace name 'Browsable' does not exist in the class ornamespace 'System.ComponentModel' Rich Microsoft Dot NET Compact Framework 3 29th Nov 2007 05:35 PM
System.ComponentModel.DefaultValue doesn't work with ascx file. jfreets2@yahoo.com Microsoft ASP .NET 0 13th Sep 2006 09:47 PM
System.ComponentModel.DefaultValue doesn't work with user control =?Utf-8?B?QVNQIERldmVsb3Blcg==?= Microsoft ASP .NET 0 13th Sep 2006 12:28 AM
<System.ComponentModel.Browsable(False)> almost does what I need active Microsoft VB .NET 2 31st Dec 2003 08:22 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:20 AM.