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

前端 未结 3 662
没有蜡笔的小新
没有蜡笔的小新 2021-02-04 11:17

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 :


[Br         


        
3条回答
  •  梦谈多话
    2021-02-04 11:21

    Here's another example comes with customizing File Dialog :

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

    Usage :

                [Category("Settings"), DisplayName("Project File:")]
                [EditorAttribute(typeof(CustomFileBrowser), typeof(System.Drawing.Design.UITypeEditor))]
                public string Project_File { get; set; }
    

提交回复
热议问题