After debugging the code i found the answer.
On first run, in above code, propertyGrid dropdown fill with Hashtable
collection. ConvertTo
method convert it into string. so it save as System.Collections.DictionaryEntry
.
when select an element from combo box it set videoProperties.VideoFormat
as System.Collections.DictionaryEntry
. So i changed ConvertTo
function as below.
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
if (value is DictionaryEntry)
{
return ((DictionaryEntry)value).Key;
}
else if (value != null)
{
return VideoFormates[value];
}
return base.ConvertTo(context, culture, value, destinationType);
}
function check if value type is DictionaryEntry
then it cast it and return the key
element of value
parameter. So combo box fill out with key
values. when form shows ConvertTo
function again called and second time return combo box values. then simplay return Hashtable
value on the base of combo box value.