Home  |  Index  |  Dotnet4all Snippets  |  Submit resources
About  |  Mail us  
Dotnet4all Logo

  Hide property in PropertyGrid (Monday, December 27, 2004)




Found the following interesting discussion in the Newsgroups:

Hide property in PropertyGrid
by:Anonymous

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


 Reply:
by:v-yiy@online.microsoft.com (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.



 Reply:
by:Anonymous

 Yes, that is exactly what I needed. Thank you!


 Reply:
by: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








0 Comments:

Post a Comment

 
Previous Posts
    - An interesting problem...
    - Arrays in VB6
    - Ask about the resource file
    - Converting from header files to Win32API declare
    - Embedded resources and the res protocol
    - DES.CreateEncryptor() Question
    - How to create a dockable controlbar for Winforms i...
    - Structure Assignment
    - Graphics from a "console" program
    - How to replace unicode characters with their HTML ...

Archives
    - 10/03/2004 - 10/10/2004
    - 10/10/2004 - 10/17/2004
    - 10/17/2004 - 10/24/2004
    - 10/24/2004 - 10/31/2004
    - 10/31/2004 - 11/07/2004
    - 11/21/2004 - 11/28/2004
    - 11/28/2004 - 12/05/2004
    - 12/05/2004 - 12/12/2004
    - 12/12/2004 - 12/19/2004
    - 12/19/2004 - 12/26/2004
    - 12/26/2004 - 01/02/2005
    - 01/23/2005 - 01/30/2005
    - 01/01/2006 - 01/08/2006
    - 09/24/2006 - 10/01/2006

Disclaimer & Terms of Use  | DotNet4All.Com concept & © 2004 - 2007 by  Zelders²  - Holland