2 Attachment(s)
Browse For Folder Is Better In VB6 Than In VB.NET
Greetings,
hope all active member of this community is fine. However as i mentioned in my few previous topic that i am/was vb6 code and now learning and shifting to vb.net.
On vb6 i use a class module to generate/show File Browser Dialog box and show it to user. It has the option where user can type/copy&Paste the path directly into a box.
Here is vb6 version screenshot:
Attachment 123345
but vb.net already has a component on tools box for that. But that doesn't has that feature to let user type/copy&paste the path.
Here is vb.net screenshot:
Attachment 123347
I check all the properties of that component, but that doesn't have anything related to that.
So, my question, is, is there any way to show that text box also in vb.net Folder Browser Dialog Box?
i hope so :)
any help will be highly appreciated?
thanks in advance
best regards
Re: Browse For Folder Is Better In VB6 Than In VB.NET
The FolderBrowserDialog, like many .NET components, is a wrapper for a Windows component. Sometimes, not all the functionality of the Windows component is surfaced via the managed API. This would be one such case. You could potentially get the handle of the actual window created by the FolderBrowserDialog object and manipulate it via the Windows API or else ditch the FolderBrowserDialog altogether and create your own managed wrapper what does surface that functionality.
1 Attachment(s)
Re: Browse For Folder Is Better In VB6 Than In VB.NET
Personally I've never liked the "FolderBrowserDialog" both in vb6 & in .Net, luckily since switching to .Net and the introduction of Windows Vista there's an api that will display a "OpenFolderDialog" which operates very similar to the OpenFileDialog and SaveFileDialog and is much more suited, in my opinion, than the FolderBrowserDialog ever could be:
Attachment 123359
I've uploaded the class that makes that happen, but using it is as simple as:
vb Code:
Using ofd As New OpenFolderDialog With {.DefaultFolder = Environment.GetFolderPath(Environment.SpecialFolder.Desktop), .InitialFolder = .DefaultFolder}
If ofd.ShowDialog(Me) <> DialogResult.Cancel Then
'Use ofd.Folder for the path to the selected folder
End If
End Using
Re: Browse For Folder Is Better In VB6 Than In VB.NET
Code:
If ofd.ShowDialog = DialogResult.OK Then
'Use ofd.Folder for the path to the selected folder
End If
Is more readable in my opinion.
Re: Browse For Folder Is Better In VB6 Than In VB.NET
Quote:
Originally Posted by
Toph
Code:
If ofd.ShowDialog = DialogResult.OK Then
'Use ofd.Folder for the path to the selected folder
End If
Is more readable in my opinion.
Then what?
Re: Browse For Folder Is Better In VB6 Than In VB.NET
than this:
Code:
If ofd.ShowDialog(Me) <> DialogResult.Cancel Then
Some people find postitive logic easier to read than negative logic... it's a personal choice. Also depends on the situation.
-tg
Re: Browse For Folder Is Better In VB6 Than In VB.NET
I use negative logic and look for not equal to, since some dialogs use 'Yes' and others us 'Ok' I find it easier to just look for 'Not Cancel'.
The point is, if you use that class I provided then you have a Folder Browsing Dialog extremely similar to an OpenFileDialog or a SaveFileDialog.
The class I posted also takes into account that WinXP and older doesn't have the new api dialog to use, so it makes a customized OpenFileDialog and shows that instead... you still use the Folder property to get the selected folder either way.
Re: Browse For Folder Is Better In VB6 Than In VB.NET
Quote:
Originally Posted by
techgnome
than this:
Code:
If ofd.ShowDialog(Me) <> DialogResult.Cancel Then
Some people find postitive logic easier to read than negative logic... it's a personal choice. Also depends on the situation.
-tg
Ahh, so that's what its called. I'm terribble at understanding "negative logic" then, it confuses me a lot because of the way my brain works.
E.g. I hate when people write. If Not Name <> "Toph" . I have to read them slowly. Why couldn't people just write.
If Name = "Toph".. Or maybe it's just me.
Re: Browse For Folder Is Better In VB6 Than In VB.NET
Quote:
Originally Posted by
ident
Then what?
You post makes no sense. I'm voicing my opinion.
Re: Browse For Folder Is Better In VB6 Than In VB.NET
Quote:
Originally Posted by
techgnome
than this:
Code:
If ofd.ShowDialog(Me) <> DialogResult.Cancel Then
Some people find postitive logic easier to read than negative logic... it's a personal choice. Also depends on the situation.
-tg
I was only checking due to Jug using the using statement. I personally would also go with not equals. As you know Any performance difference is going to be insignificant. Equals i think is faster. No sure it matters. hmm
Re: Browse For Folder Is Better In VB6 Than In VB.NET
Quote:
Originally Posted by
Toph
You post makes no sense. I'm voicing my opinion.
I know you are. I was just wanting to make sure i knew what the opinion was on.