Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get an OpenFileDialog in a custom control's property grid?

I'm creating a .net custom control and it should be able to load multiple text files. I have a public property named ListFiles with those properties set :


[Browsable(true), Category("Configuration"), Description("List of Files to Load")]
public string ListFiles
  {
     get { return m_oList; }
     set { m_oList = value; }
  }

Depending upon the type of object, (string, string[], List, ...), the property grid will allow the user to enter some data.. My goal would be to have a filtered openfiledialog in the Properties Grid of my component that would enable the user to choose multiple files and return it as an array or string (or something else...).

Sooo... Here's my question : How can I get an OpenFileDialog in a custom control's property grid?

Thanks a lot!

like image 983
koni Avatar asked Oct 04 '08 18:10

koni


1 Answers

You can use built-in UITypeEditor. It is called FileNameEditor

[EditorAttribute(typeof(System.Windows.Forms.Design.FileNameEditor), typeof(System.Drawing.Design.UITypeEditor))]

public string SomeFilePath
{
 get;
 set;
}
like image 56
SerGiant Avatar answered Sep 19 '22 14:09

SerGiant