Reputation: 423
Object of my custom class have several properties of string type. For one of the properties I use custom TypeConverter to display list of standart values for this property in PropertyGrid. Now I have problem that now this property is not displayed as simple string in PropertyGrid but as an object having Length property for itself, but I do not want it. How to fix it?
My code is like this:
class ItemAdapter
{
public ItemAdapter(Item pitem)
{
_item = pitem;
...
}
// This property shows as simple string in PropertyGrid
public string Name
{
get
{
return _item.Name;
}
set
{
_item.Name = value;
}
}
...
// This property shows Length subproperty in PropertyGrid
[TypeConverter(typeof(ItemTypeConverter))]
public string type
{
get
{
return _item.type;
}
set
{
_item.type = value;
}
}
}
I use TypeConverter only to display list of standart values, like this:
public class ItemTypeConverter : ExpandableObjectConverter
{
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
{
return true;
}
private readonly static List<string> _standardValues = new List<string>()
{
"value1",
"value2"
};
public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
{
return new System.ComponentModel.TypeConverter.StandardValuesCollection( _standardValues);
}
public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
{
return true;
}
}
Upvotes: 0
Views: 748