this problem can be solved using the BrowsableAttributes property of the GridGrid property. First create a new attribute as follows:
public class PropertyGridBrowsableAttribute : Attribute { private bool browsable; public PropertyGridBrowsableAttribute(bool browsable){ this.browsable = browsable; } }
Then add this attribute to all the properties that you want to display in the PropertyGrid:
[DisplayName("First Name"), Category("Names"), PropertyGridBrowsable(true)] public string FirstName { get { return ... } set { ... } }
Then set the BrowsableAttributes property as follows:
myPropertyGrid.BrowsableAttributes = new AttributeCollection( new Attribute[] { new PropertyGridBrowsableAttribute(true) });
This only displays the attributes associated with your property networks, and the DataGridView can access all properties with just a little more coding effort.
I will still go with Tergiver and call this behavior an error, since the documentation of the Browsable attribute clearly indicates its use only for property windows.
(Credit is sent to user "maro" at http://www.mycsharp.de/wbb2/thread.php?postid=234565 )
source share