Hide property in PropertyGrid

G

Guest

I have a situation where I want to show a property when one object is selected in a PropertyGrid, but I want to hide that property when more than one object is selected. For example, lets say I have an object with a Name property that must be unique. If one of these objects is selected by a PropertyGrid, then I want to show the Name property in the PropertyGrid so the user can change the object's name. But, if more than one of these objects are selected, then I don't want to show the Name property in the PropertyGrid because setting the value would set all of the selected objects' names to the same value which is not allowed

Any ideas

Thank you
Lance
 
Y

Ying-Shen Yu[MSFT]

Hi Lance,

You may take a look at the System.ComponentModel.MergablePropertyAttribute
class,
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemcomponentmodelmergablepropertyattributeclasstopic.asp

As the docuement describes propertyies marked with MergableProperty(false)
must be displayed seperately, the default value for properties is true.

Does it resolve your problem?
Feel free to reply this thread if you still have problems on this issue,
By the way, if you have more design-time related issues you may also post
them to their specific groups,

for winform design-time issues :
microsoft.public.dotnet.windowsforms.designtime

for webform design-time issues :
microsoft.public.dotnet.framework.aspnet.buildingcontrols

Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Community Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, please remove the word "online"
before sending mail.
 
J

Jay B. Harlow [MVP - Outlook]

Lance,
Have you reviewed the info in the following articles?

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/usingpropgrid.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/vsnetpropbrow.asp

Hope this helps
Jay

Lance said:
I have a situation where I want to show a property when one object is
selected in a PropertyGrid, but I want to hide that property when more than
one object is selected. For example, lets say I have an object with a Name
property that must be unique. If one of these objects is selected by a
PropertyGrid, then I want to show the Name property in the PropertyGrid so
the user can change the object's name. But, if more than one of these
objects are selected, then I don't want to show the Name property in the
PropertyGrid because setting the value would set all of the selected
objects' names to the same value which is not allowed.
 

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