首先定义自己要弹出的窗体,比如myform:
public partial class myform: Form
{
....//your code here
}
从UITypeEditor继承一个自定义属性编辑管理器类,参考如下:
internal class myeditor : UITypeEditor
{
public override System.Drawing.Design.UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context)
{
return UITypeEditorEditStyle.Modal;
}
public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value)
{
IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
if (edSvc != null)
{
myform f = new myform();
// your setting here
edSvc.ShowDialog(f);
}
return value;
}
public override bool GetPaintValueSupported(System.ComponentModel.ITypeDescriptorContext context)
{
return false;
}
}
在类的成员属性上指定所需的属性,如:
[EditorAttribute(typeof(myeditor), typeof(System.Drawing.Design.UITypeEditor))]
public youType youProperty
{
get{...}
set{...}
}