I want to be able to show in a propertygrid a dropdownlist that show some "string" value but return an "int" value.
For example, let set I got this class :
public class MyObjectOptions : StringConverter
{
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
{
return true;
}
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
{
MyObjectCollection mm = new MyObjectCollection();
List<String> names = new List<String>
foreach (MyObject m in mm)
{
m.Id // Need to store this somewhere ...
names.Add(m.Name);
}
return new StandardValuesCollection(name);
}
public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
{
return true;
}
}
Here is my class use in the propertygrid control
public class MyObjectProperty
{
[TypeConverter(typeof(MyObjectOptions))]
public int Id
{
get { return this.id; }
set { this.id = value; }
}
}
Like you can see, I want to store the id of the object, but I want to show it's name in the dropdownlist ... I try use a hashtable but it's doesn't work ...
BTW - I use the version 3.5 of .Net but I only use WinForm (not WPF).