I have a datagridview with info about competitors. I display each copmetitor's properties in PropertyGrid. I want some of those properties (e.g. Degree, City, Institute) to be dropboxes with values taken from database. For this purpose i can create a custom TypeConvertor like this one
class DegreeTypeConverter : StringConverter
{
static string[] _valueList = { "Bachelor", "Master", "Student" };
public override bool GetStandardValuesSupported(
ITypeDescriptorContext context)
{
return true;
}
public override bool GetStandardValuesExclusive(
ITypeDescriptorContext context)
{
return true;
}
public override StandardValuesCollection GetStandardValues(
ITypeDescriptorContext context)
{
return new StandardValuesCollection(_valueList);
}
}
[TypeConverter(typeof(DegreeTypeConverter))]
public string Degree
{
get { return _degree; }
set { _degree = value; }
}
But i want to get that valueList from database and i have 14 such properties so some universal converter would be much better than 14 converters with the only difference: valueList. Is it possible to create a TypeConverter with variable valueList (for example passed into TypeConverter as parameter in constructor)? Or maybe there's another way to have in PropertyGrid a dropbox with variable value list? Hope it was clear enough Thnx in advance