Jump to content
Xtreme .Net Talk

Setting properties for dialog on System.Windows.Forms.Design.FileNameEditor


Recommended Posts

Posted

Got my collections showing up just fine now as properties...

 

One of the subproperties though will be a file name. I have the following code setting the property to call up an OpenFileDialog...

 

        <Editor(GetType(System.Windows.Forms.Design.FileNameEditor), GetType(System.Drawing.Design.UITypeEditor))> _
       Public Property FileName() As String
           Get
               Return _FileName
           End Get
           Set(ByVal Value As String)
               _FileName = Value
           End Set
       End Property

 

So far so good... dialog comes up. The problem is that it is just a default one. I need it to have the following set for it:

 

....1. Title

....2. DefaultExt

....3. InitialDirectory

 

How would this be done in this case? I haven't been able to find any information on this. Thanks!

"Programmers are tools for converting caffeine into code."

 

Madcow Inventions -- Software for the Sanity Challenged.

Posted (edited)

Ok... found the solution for this and so I will post as follows since I didn't see it listed anywhere else on the net.

 

 

In a separate class...

 

[size=2][color=#0000ff]Public [/color][/size][size=2][color=#0000ff]Class[/color][/size][size=2][color=#000000] ExFileNameEditor[/color]
[/size][size=2][color=#0000ff]    Inherits[/color][/size][size=2] System.Windows.Forms.Design.FileNameEditor
[/size][size=2][color=#0000ff]    Protected [/color][/size][size=2][color=#0000ff]Overrides [/color][/size][size=2][color=#0000ff]Sub[/color][/size][size=2] InitializeDialog([/size][size=2][color=#0000ff]ByVal[/color][/size][size=2] _OFD [/size][size=2][color=#0000ff]As[/color][/size][size=2] System.Windows.Forms.OpenFileDialog)
       _OFD.Title = "My File Dialog"
       _OFD.Filter = "Text File (*.txt)|*.txt"
       _OFD.InitialDirectory = System.Environment.CurrentDirectory
[/size][size=2][color=#0000ff]    End[/color][/size][size=2][color=#0000ff]Sub
End[/color][/size][size=2][color=#0000ff]Class[/color][/size]

 

For your property us this instead...

 

[size=2]
<Editor([/size][size=2][color=#0000ff]GetType[/color][/size][size=2](ExFileNameEditor), [/size][size=2][color=#0000ff]GetType[/color][/size][size=2](System.Drawing.Design.UITypeEditor))> _[/size]

 

Welcom to your custom FileNameEditor dialog... easy huh?:D

Edited by mooman_fl

"Programmers are tools for converting caffeine into code."

 

Madcow Inventions -- Software for the Sanity Challenged.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...