By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,815 Members | 1,151 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,815 IT Pros & Developers. It's quick & easy.

Hiding properties from the Forms Designer

P: n/a
(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
Share this Question
Share on Google+
3 Replies


P: n/a
"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

P: n/a
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

P: n/a
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.