简体   繁体   English

属性网格自定义编辑器

[英]Property Grid Custom Editor

I have a custom form Names "Form1" that I want to open through propertygrid control. 我有一个要通过propertygrid控件打开的自定义表单名称“ Form1”。

我要这样在此处输入图片说明

Code here 在这里编码

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

You need to define a class that inherits from UITypeEditor who's job will be to display Form1 . 您需要定义一个从UITypeEditor继承的类,该类的工作是显示Form1 This type is what goes into the EditorAttribute (not Form1 ). 这种类型是进入EditorAttribute (不是Form1 )的东西。 The sample here is more or less what you need to implement. 这里的示例或多或少是您需要实现的。 Basically, you override GetEditorStyle to return UITypeEditorEditStyle.Modal and override EditValue to call IWindowsFormsEditorService.ShowDialog on an instance of your form. 基本上,您重写GetEditorStyle以返回UITypeEditorEditStyle.Modal并重写EditValue以在表单实例上调用IWindowsFormsEditorService.ShowDialog

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM