468,321 Members | 1,686 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,321 developers. It's quick & easy.

Hiding properties from the Forms Designer

(VB.Net 2003)
I have a UserControl that exposes a number of public properties.

When using this control on a.n.other Form, how can(?) I prevent
the Forms Designer from adding code into InitializeComponent to
set any or all of these properties when I save the form?

There are one or two that I /might/ want set in this way, but I'd like
to "persuade" the Designer to leave the rest well alone ...

Any suggestions?
TIA,
Phill W.
Nov 21 '05 #1
3 1613
"Phill. W" <P.A.Ward@o-p-e-n-.-a-c-.-u-k> schrieb:
I have a UserControl that exposes a number of public properties.

When using this control on a.n.other Form, how can(?) I prevent
the Forms Designer from adding code into InitializeComponent to
set any or all of these properties when I save the form?
\\\
< _
DesignerSerializationVisibility( _
DesignerSerializationVisibility.Hidden _
) _ _

Public Property...
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Nov 21 '05 #2
Hi,

http://msdn.microsoft.com/library/de...classtopic.asp

Ken
--------------------
"Phill. W" <P.A.Ward@o-p-e-n-.-a-c-.-u-k> wrote in message
news:dh**********@yarrow.open.ac.uk...
(VB.Net 2003)
I have a UserControl that exposes a number of public properties.

When using this control on a.n.other Form, how can(?) I prevent
the Forms Designer from adding code into InitializeComponent to
set any or all of these properties when I save the form?

There are one or two that I /might/ want set in this way, but I'd like
to "persuade" the Designer to leave the rest well alone ...

Any suggestions?
TIA,
Phill W.

Nov 21 '05 #3
There are several ways to do this. People will often refer to the
BrowsableAttribute and override of the relavent properties. This however is
an inefficient and incorrect way to do things.

At design time, the IDE provides for the dedicated control designer assigned
to your component to filter the properties and events so that they are not
seen by the IDE. This is accomplished using the
ControlDesigner.PreFilterProperties and ControlDesigner PostFilterProperties
methods. Furthermore, if you use reflection or indeed the PropertyGrid at
runtime you can create custom filters by having your class implement the
ICustomTypeDescriptor interface. This enables you to return an edited or
even augmented list of properties, events and attributes seen by the
reflection API's

Of course, at runtime the properties will still be available but if the
properties are filtered at design time they will not be visible to the code
serializer. IMO it's simpler to provide a designer with a property filter
than override N number of properties and mess with their browsability.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Phill. W" <P.A.Ward@o-p-e-n-.-a-c-.-u-k> wrote in message
news:dh**********@yarrow.open.ac.uk...
(VB.Net 2003)
I have a UserControl that exposes a number of public properties.

When using this control on a.n.other Form, how can(?) I prevent
the Forms Designer from adding code into InitializeComponent to
set any or all of these properties when I save the form?

There are one or two that I /might/ want set in this way, but I'd like
to "persuade" the Designer to leave the rest well alone ...

Any suggestions?
TIA,
Phill W.

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Scott Kilbourn | last post: by
2 posts views Thread by Juan Pedro Gonzalez | last post: by
1 post views Thread by =?Utf-8?B?aXd1Y29tcHV0ZXJnZWVrMDU=?= | last post: by
1 post views Thread by howard w | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.