在属性网格中,我为一个属性实现了一个StringConverter来显示一个值列表,一个UITypeEditor来打开一个表单进行编辑。
每项工作都分开。但是,当我把它们放在一起,StringConverter和UITypeEditor时,我没有看到省略号来编辑我的属性。 省略号隐藏在下拉列表的箭头下方。
有什么想法吗?
以下代码 - 如果有帮助
[Editor(typeof(VideoDeviceEditor), typeof(UITypeEditor))]
[TypeConverter(typeof(VideoDevicesList))]
public class VideoDevices
{
}
public class VideoDevicesList : System.ComponentModel.StringConverter
{
public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
{
ChannelPropertyConfiguration inst = (ChannelPropertyConfiguration)context.Instance;
List<string> lgs = new List<string>();
lgs.Add("Microsoft Life Cam");
lgs.Add("Logitech Web Cam");
return new StandardValuesCollection(lgs);
}
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
{
return true;
}
public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
{
return true;
}
}
public class VideoDeviceEditor : UITypeEditor
{
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
{
return UITypeEditorEditStyle.Modal;
}
public override object EditValue(ITypeDescriptorContext context, System.IServiceProvider provider, object value)
{
IWindowsFormsEditorService svc = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
if (svc != null)
{
MessageBox.Show("OK");
}
return value;
}
}