|
-
Jan 30th, 2015, 08:16 AM
#1
Thread Starter
Hyperactive Member
-
Jan 30th, 2015, 08:43 AM
#2
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.
-
Jan 30th, 2015, 12:08 PM
#3
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:

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
Last edited by JuggaloBrotha; Jan 30th, 2015 at 12:14 PM.
-
Jan 30th, 2015, 02:36 PM
#4
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.
-
Jan 30th, 2015, 03:23 PM
#5
Re: Browse For Folder Is Better In VB6 Than In VB.NET
 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?
-
Jan 30th, 2015, 03:27 PM
#6
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
-
Jan 30th, 2015, 03:41 PM
#7
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.
-
Jan 30th, 2015, 03:52 PM
#8
Re: Browse For Folder Is Better In VB6 Than In VB.NET
 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.
-
Jan 30th, 2015, 03:56 PM
#9
Re: Browse For Folder Is Better In VB6 Than In VB.NET
 Originally Posted by ident
Then what?
You post makes no sense. I'm voicing my opinion.
-
Jan 30th, 2015, 04:00 PM
#10
Re: Browse For Folder Is Better In VB6 Than In VB.NET
 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
-
Jan 30th, 2015, 04:01 PM
#11
Re: Browse For Folder Is Better In VB6 Than In VB.NET
 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.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|