Archived

This topic is now archived and is closed to further replies.

jharkey

Property Window in VS.NET

Recommended Posts

i was wondering if anyone knew how the property window works in VS.NET. it seems like a list view, but when you click on it, it turns that square into a combo box. now, i have lots of ideas on how to go about this manually, but is there already a control for it? im using c#. thanks in advance

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
The property grid is available to you just as any other control (list boxes, buttons, ...). You can add it to the toolbox with Tools->Customize toolbox and in the .NET Framework Components tab, check PropertyGrid.

I found it a little strange to use, but it''s quite simple; IIRC you choose which object it has to show the properties of (grid.SelectedObject = myobj, and that''s about it. Any changes made in the property grid will automatically be made to the object itself.

If I''m not mistaken you can choose which properties are made public to the property grid using some attribute (forgotten how it''s called). Also, you can make your own "value editors" (for example, if an object has a color property, you can attach a color wheel thingie that will appear each time the user wants to choose a different color.)

Share this post


Link to post
Share on other sites
I stand corrected here, you are right :-) Hm, I was looking into this some time ago, but from a different angle - I must have overlooked that the property editor control is available. Shame on me.

THe attribute is "Browsable", btw.

Regards

Thomas Tomiczek
THONA Consulting Ltd.
(Microsoft MVP C#/.NET)

Share this post


Link to post
Share on other sites
The PropertyGrid is absolutely great for storing application settings. It''s incredibly convenient to put all settings in a class and simply have the user modify that class.

There''s also another attribute, Description, I think, that lets you give your properties descriptions. You can also put them into categories with another attribute.

Share this post


Link to post
Share on other sites