UltraGrid如何通过EditorAttribute设置自定义编辑器
我试图让 UltraGrid 使用通过编辑器属性设置的自定义编辑器。然而,它似乎忽略了该设置,只使用其内部编辑器。这是我的代码:
public class DialogEditor : UITypeEditor
{
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
{
return UITypeEditorEditStyle.Modal;
}
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
{
MessageBox.Show("Testing 1,2,3");
return base.EditValue(context, provider, value);
}
}
public class TestContainer
{
public TestContainer(int id, string name)
{
Id = id;
Name = name;
}
[Editor(typeof(DialogEditor), typeof(UITypeEditor))]
public int Id { get; set; }
public string Name { get; set; }
public override string ToString()
{
return string.Format("{0} : {1}", Id, Name);
}
}
测试通过:
var data = new List<object>
{
new TestContainer(1, "one"),
new TestContainer(2, "two"),
};
ultraGrid1.DataSource = data;
I am trying to get an UltraGrid to use a custom editor set via the Editor Attribute. However it seems to ignore the setting and just use its internal editor. Here is my code:
public class DialogEditor : UITypeEditor
{
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
{
return UITypeEditorEditStyle.Modal;
}
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
{
MessageBox.Show("Testing 1,2,3");
return base.EditValue(context, provider, value);
}
}
public class TestContainer
{
public TestContainer(int id, string name)
{
Id = id;
Name = name;
}
[Editor(typeof(DialogEditor), typeof(UITypeEditor))]
public int Id { get; set; }
public string Name { get; set; }
public override string ToString()
{
return string.Format("{0} : {1}", Id, Name);
}
}
Tested via:
var data = new List<object>
{
new TestContainer(1, "one"),
new TestContainer(2, "two"),
};
ultraGrid1.DataSource = data;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
答案:你不能。 UITypeEditor 仅用于 PropertyGrid。
请改用 Infragistics 可嵌入编辑器。
Answer: You can't. UITypeEditor are only used for PropertyGrids.
Use the Infragistics Embeddable Editors instead.