根据MSDN的演练http://msdn.microsoft.com/en-us/library/ms171840.aspx,我为我的Smiley类型编写了一个自定义的UITypeEditor
当用户单击省略号时,我的UITypeEditor将启动一个模式对话框。
public class SmileyEditor : UITypeEditor
{
public override UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context)
{
return UITypeEditorEditStyle.Modal;
}在经历了许多痛苦之后,我发现如果我的类型是一个类,它就可以工作,但如果它是一个枚举就不行了。到底怎么回事?
[Editor(typeof(SmileyEditor), typeof(System.Drawing.Design.UITypeEditor))]
public Smiley face { get; set; }如果Smiley类型是枚举,则属性网格不会显示省略号按钮,而是一个下拉列表。为什么?
发布于 2012-09-25 19:03:18
显然,当系统类型编辑器存在时,PropertyGrid更喜欢它而不是自定义编辑器。一种解决方法是使用引用覆盖GetStandardValuesSupported方法的TypeConvertorAttribute的TypeConvertor来注释您的类型。请参阅https://stackoverflow.com/a/4067173/284795
https://stackoverflow.com/questions/12580444
复制相似问题