Custom component property question

D

Du Dang

I'm trying to make a custom component and one of the properties required the
user to enter a path of a folder. The question is how do I allow the user to
use a "folder browser" pick the path rather than let him/her type the path
in manually (ie click on the "three dot" beside the field in visual studio
and a folder browser will pop up).


Currently this his how I code it using raw string.

[Category("AutoSaver")]
[Description(@"The directory where the setting file is stored.")]
public string SaveTo {
get {
return m_SaveTo;
}
set {
if (Directory.Exists(value)){
if (value.EndsWith("\\")){
m_SaveTo = value;
}
else {
m_SaveTo = value + "\\";
}
}
else {
m_SaveTo = System.Environment.CurrentDirectory + "\\";
}
}
}


If I'm not explaining myself cleary and confused you some how, just click on
the three dot beside "SelectedPath" property under FolderBrowserDialog
control in visual studio and you'll see what I mean.

Any help is greatly appreciated.

Thanks,

Du
 
D

Du Dang

Found it !!!

Just add the following attribute to the property:

[Editor(typeof(FolderNameEditor), typeof(UITypeEditor))]


Regard,

Du
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top