カスタムコントロールのプロパティグリッドでOpenFileDialogを取得するにはどうすればよいですか?

StackOverflow https://stackoverflow.com/questions/170791

質問

.netカスタムコントロールを作成していますが、複数のテキストファイルを読み込むことができるはずです。これらのプロパティが設定されたListFilesという名前のパブリックプロパティがあります:


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

オブジェクトのタイプ(string、string []、List、...)に応じて、ユーザーはプロパティグリッドを使用してデータを入力できます。ユーザーが複数のファイルを選択し、配列または文字列(または他の何か...)としてそれを返すことができるようにする私のコンポーネントの。

すみません...私の質問です:カスタムコントロールのプロパティグリッドでOpenFileDialogを取得するにはどうすればよいですか

どうもありがとう!

役に立ちましたか?

他のヒント

組み込みのUITypeEditorを使用できます。 FileNameEditor

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

public string SomeFilePath
{
 get;
 set;
}

ファイルダイアログのカスタマイズに付属する別の例:

CustomFileEditor.cs

using System.Windows.Forms;
using System.Windows.Forms.Design;

namespace YourNameSpace
{
    class CustomFileBrowser : FileNameEditor
    {
        protected override void InitializeDialog(OpenFileDialog openFileDialog)
        {
            base.InitializeDialog(openFileDialog);
            openFileDialog.Title = "Select Project File : ";
            openFileDialog.Filter = "Project File (*.proj)|*.proj"; ;
        }
    }

}

使用法:

            [Category("Settings"), DisplayName("Project File:")]
            [EditorAttribute(typeof(CustomFileBrowser), typeof(System.Drawing.Design.UITypeEditor))]
            public string Project_File { get; set; }
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top