Reputation: 10479
I would like to add a feature like the following to a custom control, but I am unsure how to do this :
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
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