Property Grid Custom Editor

时间:2013-06-18 06:27:43

标签: c# .net propertygrid

我有一个自定义表单Names" Form1"我想通过propertygrid控件打开。

I want to make it like this enter image description here

此处代码

[CategoryAttribute("Extended Properties"),
        EditorAttribute(typeof(System.Windows.Forms.Form1), typeof(System.Drawing.Design.UITypeEditor))]
        [TypeConverter(typeof(ExpandableObjectConverter))]
        public string Path { get; set; }

1 个答案:

答案 0 :(得分:0)

您需要定义一个继承自UITypeEditor的人,该职位将显示Form1。这种类型属于EditorAttribute(不是Form1)。样本here或多或少是您需要实现的。基本上,您覆盖GetEditorStyle以返回UITypeEditorEditStyle.Modal并覆盖EditValue以在表单实例上调用IWindowsFormsEditorService.ShowDialog