如何添加一个选择文件夹属性,该属性在IDE中显示为3个点

时间:2016-04-03 00:33:23

标签: c# user-controls

我想在自定义控件中添加如下功能,但我不确定如何执行此操作:

enter image description here

如何在c#

中向开发人员IDE中显示如下所示的自定义用户控件添加属性(使用browse [...]按钮强制选择文件夹)

1 个答案:

答案 0 :(得分:3)

使用“编辑器”属性指定属性的编辑器。确保在项目中引用了System.Design.dll。

public partial class UserControl1 : UserControl
{
    public UserControl1()
    {
        InitializeComponent();
    }

    [Editor(typeof(System.Windows.Forms.Design.FolderNameEditor), typeof(System.Drawing.Design.UITypeEditor))]
    public string SelectedPath
    {
        get;
        set;
    }
}