| | |
Open file dialog
Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Jan 2009
Posts: 68
Reputation:
Solved Threads: 0
•
•
•
•
If you are using VS 2008 or VS 2005 just drop an OpenFileDialog from the toolbox on your form
Yes, I am using VS 2008 and i've drag and drop an openFileDialog but how can I initiate it. It simply shows below the Main form i've created with buttons on it.
Do I need to initiate behind any button click event?
thx
Hello, gallian99.
This may help you: OpenFileDialog Class - that for case if you're not dropped it on your form.
and this: Opening Files Using the OpenFileDialog Component - if it is on your form.
This may help you: OpenFileDialog Class - that for case if you're not dropped it on your form.
and this: Opening Files Using the OpenFileDialog Component - if it is on your form.
So what if you can see the darkest side of me?
No one would ever change this animal I have become
Help me believe it's not the real me
Somebody help me tame this animal
No one would ever change this animal I have become
Help me believe it's not the real me
Somebody help me tame this animal
You essentially do something like this
C# Syntax (Toggle Plain Text)
private void button1_Click(object sender, System.EventArgs e) { if(openFileDialog1.ShowDialog() == DialogResult.OK) { // The ShowDialog does just what it says //Do whatever you like to do when you clicked OK button in the dialog, see also hints by Antenka } }
Last edited by ddanbe; Jan 4th, 2009 at 3:01 pm.
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Make love, no war. Cave ab homine unius libri.
Danny
•
•
Join Date: Jan 2009
Posts: 68
Reputation:
Solved Threads: 0
Thanks that helps...
Can you also show me how to return the selected folder path in a label once user selects/browses the folder and presses ok in folderBrowserDialog
thx
Can you also show me how to return the selected folder path in a label once user selects/browses the folder and presses ok in folderBrowserDialog
thx
•
•
•
•
You essentially do something like this
C# Syntax (Toggle Plain Text)
private void button1_Click(object sender, System.EventArgs e) { if(openFileDialog1.ShowDialog() == DialogResult.OK) { // The ShowDialog does just what it says //Do whatever you like to do when you clicked OK button in the dialog, see also hints by Antenka } }
•
•
Join Date: Aug 2008
Posts: 1,735
Reputation:
Solved Threads: 186
Have you checked what properties and how to use the dialogbox as per the helpfile? If we hand you all the code you dont learn how to find these things and will end up frustrated as you have to ask for everything and it takes longer.
If you look at the dialogbox in the helpfile, it has examples, it shows how to get the filename and stuff back, then the label component has properties of its own and you can see how to apply them..
Far more pride and joy is got by doing it yourself.
If you look at the dialogbox in the helpfile, it has examples, it shows how to get the filename and stuff back, then the label component has properties of its own and you can see how to apply them..
Far more pride and joy is got by doing it yourself.
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
•
•
Join Date: Jan 2009
Posts: 68
Reputation:
Solved Threads: 0
Totally agree to your message. I just figured it out. Thanks to all the forum members who replied. Just one more thing as of now, can I truncate the selectedPath to only the folder name that the users selects. folderName shows the complete path and i don't have much space in the designed label to cater to the long and lengthy paths.
private void button2_Click(object sender, EventArgs e)
{
DialogResult result = folderBrowserDialog1.ShowDialog();
if (result == DialogResult.OK)
{
folderName = folderBrowserDialog1.SelectedPath;
}
lPath.Text = folderName;
}
private void button2_Click(object sender, EventArgs e)
{
DialogResult result = folderBrowserDialog1.ShowDialog();
if (result == DialogResult.OK)
{
folderName = folderBrowserDialog1.SelectedPath;
}
lPath.Text = folderName;
}
•
•
•
•
Have you checked what properties and how to use the dialogbox as per the helpfile? If we hand you all the code you dont learn how to find these things and will end up frustrated as you have to ask for everything and it takes longer.
If you look at the dialogbox in the helpfile, it has examples, it shows how to get the filename and stuff back, then the label component has properties of its own and you can see how to apply them..
Far more pride and joy is got by doing it yourself.
Sure, you can, e.g. using method LastIndexOf() to find the last slash character in the returned string ... your folder name will be placed after the last slash.
Last edited by Antenka; Jan 4th, 2009 at 3:59 pm. Reason: Mistaken :(
So what if you can see the darkest side of me?
No one would ever change this animal I have become
Help me believe it's not the real me
Somebody help me tame this animal
No one would ever change this animal I have become
Help me believe it's not the real me
Somebody help me tame this animal
![]() |
Similar Threads
- open save dialog box error (PHP)
- Help Web Browser Open File Dialog Problems (VB.NET)
- Open file Dialog in asp.net (ASP.NET)
- Opening a .pdf file at the clientside without the open/save dialog box (ASP.NET)
- File Dialog window, save dialog window (Python)
- vb6/common dialog/access db (Visual Basic 4 / 5 / 6)
Other Threads in the C# Forum
- Previous Thread: Need advice on matrix input
- Next Thread: TagPrefix and Assembly error
| Thread Tools | Search this Thread |
.net access activedirectory ado.net algorithm array barchart bitmap box broadcast buttons c# check checkbox client color combobox connect control conversion csharp custom database datagrid datagridview dataset datetime degrees development disabled displayingopenforms draganddrop drawing encryption enum event excel file foreach form format forms ftp function gdi+ httpwebrequest image index index-error input install java label list listbox listener mandelbrot math mathematics mouseclick mysql operator path photoshop picturebox pixelinversion post prime programming radians regex remote remoting richtextbox serialization server setup sleep socket sql statistics stream string table tcp text textbox thread time timer update user usercontrol validation visualstudio webbrowser windows winforms wpf xml






