Strategy for presenting property "consensus" in a property grid?

M

Michael Kairys

I want to show the properties of multiple objects in a property grid in some
meaningful fashion.

One approach would be to have the properties which all objects have in
common displayed normally and the properties which not all objects have in
common displayed with the corresponding property grid row greyed-out. Then
when the user clicked on a row he would be able to edit the property
normally, and doing so would apply it to all objects

This would look good, but I don't know if it is possible to implement. I
could perhaps do it by controlling the IsReadOnly attribute of each property
(If they are readonly I believe they would be greyed) but (1) that doesn't
seem all that easy (see below), and (2) I don't know if I could make it
un-readonly in response to a mouse click.

So:

(1) Any suggestions about implementing this approach?
(2) Any suggestions about a better approach?


TIA,
Michael Kairys
Senior Engineer | SL Corporation | http://www.sl.com


P.S.
In a reply to another topic in this group I saw:
2. How to change readonly attribute of a property at run time?

I know one solution that is not really trivial: your class must implement
ICustomTypeDescriptor and you must also derive a new class from
PropertyDescriptor. Put together you have full control on the behaviour of
your object properties. Concerning your case, you would override the
PropertyDescriptor.IsReadOnly property.
 
M

Michael Kairys

Visual Studio does this: if you open a form in Design view, select a
control, and view its properties you get a property sheet; if you then
select a second control as well, the property sheet modifies itself by (1)
removing the rows of properties that can't realistically be applied to
multiple controls, and (2) showing blank for properties that can, but that
don't have the same values. These rows can still be used to set the
properties of all the selected controls at once.

This would be fine for my purposes, if only I knew how to do it!
 
M

Michael Kairys

I see now that my (2) will be done for me if I use
PropertyGrid.SelectedObjects instead of SelectedObject. However I don't see
how to do (1), even using ICustomTypeDescriptor. I shall start a new thread
for this question.
 

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