Property Grid issue

G

Guest

Hi,
I would like to reflect on multiple objects and filter their properties
based a criteria, consolidate these properties and show them in the Property
Gird. Is there any way to do that ?? Any help is appreciated.

Thanks,
Ramesh
 
B

Bob Powell [MVP]

I think this will be possible using a class that implements
ICustomTypeDescriptor.

This class can return a list of PropertyInfo items that can be constructed
on the fly. It would effectively act as a buffer between the PropertyGrid
and the classes that you wanted to edit or display.

I've done this sort of thing before in an example in which a component
returns a specific set of propertied dependent on the setting of one of it's
member properties.

I'll see if I can dig up some code this weekend.


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

Guest

Thanks for your reply. I would highly appreciate if you could provide a code
snippet.
My application provides a property grid so that users can configure some
controls.
I need to extract properties from multiple objects and show them in the grid
to edit.

I understand that ICustomTypeDescriptor.GetProperties returns a
PropertyDescriptorCollection. But when you assign an instance of
PropertyDescriptorCollection to PropertyGrid.SelectedObject, the grid
displays the public properties of the collection object but not the
properties that I want. Is that right ? Or am i missing something ?

Thanks,
Ramesh
 
G

Guest

Bob,

I guess I figured it out.

Ramesh said:
Thanks for your reply. I would highly appreciate if you could provide a code
snippet.
My application provides a property grid so that users can configure some
controls.
I need to extract properties from multiple objects and show them in the grid
to edit.

I understand that ICustomTypeDescriptor.GetProperties returns a
PropertyDescriptorCollection. But when you assign an instance of
PropertyDescriptorCollection to PropertyGrid.SelectedObject, the grid
displays the public properties of the collection object but not the
properties that I want. Is that right ? Or am i missing something ?

Thanks,
Ramesh
 
B

Bob Powell [MVP]

I looked for the sample this weekend but it's not on the machine I thought
it was on.

I have asked someone to look for it on another server.

I'll post it later for completeneness...

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

Guest

Thanks Bob.
Also I have a question. I am using property grid in my app to configure some
custom controls at runtime in my app. How can I show the Events tab in the
grid ?
Can you please help me. the PropertyTabs.AddTabs does not work. Also the
grid is in runtime mode. No siting nor design time support.

Thanks,
Ramesh
 

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

Top