Reputation: 323
I've created a control that have some properties i am trying to add the properties to the Property Grid, Also how to choose the Control that edits the property's value in the property grid
Thanks
Upvotes: 0
Views: 664
Reputation: 54552
You add propery's to the designer by using attributes from System.ComponentModel.CategoryAttribute which is found in the System.ComponentModel Namespace.
using System.ComponentModel;
[Category("Layout"), Description("Your Description Here"), DefaultValue(true)]
bool yourPropertyName
{
.....
}
This will put your property in the Layout Category of your Property grid with a description of "Your Description Here" with a DefaultValue of true . If you do not assign a Category your Property will be assigned to the Misc. Category by default if your are in category view.
Upvotes: 1
Reputation: 11252
Are you instantiating your control on a form or another control in the Visual Studio designer? You should be able to view an edit all properties, such as strings or boolean values, as long as those properties are public and have a get/set accessor.
To customize how the properties appear on the property grid, you can use attributes such as DefaultValue.
I have no idea what you mean by the second half of your sentence. The control that sets the properties is always the parent control when using the Visual Studio designer.
Upvotes: 1