I have a textBox which gets filled with a path, acquired from a database (but that's irrelevant). So I want to have a FolderBrowserDialog button where I open -> navigate through the folders and select a path (i.e. by selecting a certain folder) and then OK/Save-ing this path and it to be updated in the textBox.
So in the whole case - I don't know how to use the OpenFolderBrowserDialog, because when I drag it - it only goes in the bottom of the page, but I want to place it as a button on a certain place in my WinForm. And also - how is the selected path saved into a (i.e. string) variable so I can set it as the value of the textbox? A certain method?
Try like below it will help you..
Place a Text box
, Button
and FolderBrowserDialog
in your Form
like below...
Then Double click the button
and create Button click Event
on your code like below..
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
If (FolderBrowserDialog1.ShowDialog() = DialogResult.OK) Then
TextBox1.Text = FolderBrowserDialog1.SelectedPath
End If
End Sub
Then run it.. Now you can open the Folder Browser dialog by clicking the Browse Button..
After selecting the folder Path the path will assigned to Text Box
You can also refer this Article for full reference : FolderBrowserDialog