I am trying to use property grid for displaying data. I have to write StringConverters for my predefined string constants so that they can be shown on a combo box.
Consider a list of colors and another list of angles 0,90,180,270. There are many such lists I want to display on the grid.
I am writing new classes deriving from StringConverters and overriding GetStandardValues
class AngleConverter : StringConverter
{
string[] Units = { "0", "90", "180","270" };
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
{
return true;
}
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
{
return new StandardValuesCollection(Units);
}
public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
{
return true;
}
}
Class UnitConverter : ... Same code except change in the string array. I use this Class before the property like [TypeConverter(typeof(AngleConverter))]. I need to create new class if I want to add a string list to be displayed in a list box on the grid.
Is there a generic way of doing this without creating new classes everytime.
Thanks --Hari