C# 如何在c中双击控件打开模态对话框

C# 如何在c中双击控件打开模态对话框,c#,controls,design-time,C#,Controls,Design Time,我正在为c WinForms编写一个控件,我有一个集合类型的属性 当用户选择此属性时,使用。。。将显示“新建模式”对话框。所有这些工作都很好,我创建了: public class ItemsEditor : UITypeEditor 在这个类中,我使用override EditValue方法并使用ShowDialog打开模态编辑器。正如我所说,这项工作很好 但是,我想在控件的用户双击它时打开此对话框 为此,我已继承ControlDesigner: public class MyControlD

我正在为c WinForms编写一个控件,我有一个集合类型的属性

当用户选择此属性时,使用。。。将显示“新建模式”对话框。所有这些工作都很好,我创建了:

public class ItemsEditor : UITypeEditor
在这个类中,我使用override EditValue方法并使用ShowDialog打开模态编辑器。正如我所说,这项工作很好

但是,我想在控件的用户双击它时打开此对话框

为此,我已继承ControlDesigner:

public class MyControlDesigner : ControlDesigner
在这个类中,我继承了下一个方法:

public override void DoDefaultAction()
{
    string propertyName = "Items";                      
    IServiceProvider provider = (IServiceProvider)GetService(typeof(IServiceProvider));      

    PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(MyControl);

    PropertyDescriptor property = properties[propertyName];

    UITypeEditor editor = (UITypeEditor)property.GetEditor(typeof(UITypeEditor));

    editor.EditValue(provider, null);
}
正如可以看到的,我放了一些随机代码,当然不起作用

有谁能帮我解决这个问题,以及如何双击打开属性

谢谢你的帮助

致意
Bojan

我不确定双击显示编辑器的可行性,但另一种方法可能是使用ActionList(又名SmartTag)——请参阅文章:

对不起,但请改写您的问题。这很难理解。例如:当您双击ListView控件时,应该打开列编辑器。