PropertyGrid

  • Thread starter Alexander Vasilevsky
  • Start date

A

Alexander Vasilevsky

Made his UserControl, want to customize it using PropertyGrid, properties,
which must show it is my own, without the basic properties of the class. How
can I make a parent does not show properties?

http://www.alvas.net - Audio tools for C# and VB.Net developers
 
Ad

Advertisements

B

Bob Powell [MVP]

You can create a designer for your control and override the
PostFilterProperties method to remove the properties that you don't want to
see.

See ControlDesigner and DesignerAttribute.

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

VisualHint

Hello Alexander,

The fact that you will need the parent properties at designtime (like
position, size, and so on) makes me think that this is at runtime that
you want to hide the parent properties of your custom control. Is it
the case? If yes, you have three possibilities:

- Derive your class from ICustomTypeDescriptor and implement
GetProperties to return only the properties you want.
- If you use .Net 2, you can set this functionaly in a separate class
and use TypeDescriptionProvider to register your TypeDescriptor.
- Create your own TypeConverter and implement GetProperties to return
only the properties you want. Attach this converter to your type with
the TypeConverterAttribute.

The Property Grid Resource List will list you the right resources to
implement one of these solutions.

You will be able to implement a generic way of filtering the parent
properties. The PropertyDescriptor class gives you the ComponentType
property so that you know the type of the target instance.
Type.IsAssignableFrom will tell you if your property belongs to your
custom control or to an ancestor type.

Best regards,

Nicolas Cadilhac @ VisualHint (http://www.visualhint.com)
Home of Smart FieldPackEditor.Net / DateTimePicker replacement (http://
www.visualhint.com/index.php/fieldpackeditor)
Home of Smart PropertyGrid for .Net and MFC (http://www.visualhint.com/
index.php/propertygrid)
Microsoft PropertyGrid Resource List - http://www.propertygridresourcelist.com
 
Ad

Advertisements

V

VisualHint


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

Similar Threads

PropertyGrid 0
PropertyGrid 0
PropertyGrid 1
PropertyGrid 1
PropertyGrid 2
PropertyGrid 6
PasswordChar and PropertyGrid 0
Propertygrid and exceptions 3

Top