Kraang Prime
Kraang Prime

Reputation: 10479

How can I add a choose folder property that shows in the IDE with the 3 dots

I would like to add a feature like the following to a custom control, but I am unsure how to do this :

enter image description here

How can I add a property to a custom usercontrol that shows up like this in the developer IDE (forcing a folder selection with browse [...] button) in c#

Upvotes: 1

Views: 90

Answers (1)

ma7r
ma7r

Reputation: 396

Use an "Editor" attribute to specify the editor of the property. Make sure you have a reference to System.Design.dll in your project.

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;
    }
}

Upvotes: 3

Related Questions