Create new class which inherit StringCoverter, and 3 methods:
internal class List2PropertyConverter : StringConverter
{
public override bool
GetStandardValuesSupported(
ITypeDescriptorContext context)
{
//True - means show a Combobox
//and False for show a Modal
return true;
}
public override bool
GetStandardValuesExclusive(
ITypeDescriptorContext context)
{
//False - a option to edit values
//and True - set values to state readonly
return true;
}
public override StandardValuesCollection
GetStandardValues(
ITypeDescriptorContext context)
{
return new StandardValuesCollection(
new string[] {"test1", "test2", "..."});
}
}
Add variable and encapsulate it:
private string testValue;
[Browsable(true)]
[Category("Category name")]
[TypeConverter(typeof(List2PropertyConverter))]
public string TestValues
{
get { return testValue; }
set { testValue = value; }
}
PropertyGrid has 4 attributes for a manage properties:
[Browsable(bool)] - Visible/Hide property
[ReadOnly(bool)] - Editing (true/false)
[Category(string)] - Group of properties
[Description(string)] - Description of the property
Regards,