Using
_
on the declaration of a class
Actually this is entirely possible. The first and easiest way is to set the grid's BrowsableAttributes property:
propGraph.BrowsableAttributes = new AttributeCollection(
new Attribute[]
{
new CategoryAttribute("Appearance")
});
This will filter out all properties that do NOT match the attribute-types you supply. Unfortunately this is a positive filter rather than a negative filter which makes it less useful IMHO.
Second, and equally easy, you can create a simple wrapper around the object you want to display in the PropertyGrid and re-define whatever properties you want to hide/etc. as passthrough properties:
public class MyDerivedControl : public TextBox
{
[Browsable(false)]
[Category("MyCustomCategory")]
public new bool Enabled
{
get { return base.Enabled }
set { base.Enabled = value; }
}
}
Pop that into a property grid and the Enabled property will be hidden.
Third, you can customize the PropertyGrid itself and get into the world of type descriptors and so forth, but if all you want to do is hide a couple properties, this is overkill.
Hope this helps.