473,473 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

how to open an open dialogbox using c#.net

11 New Member
hi frnds,

iam shaam working on c#.net. i want the way how to open an open dialog box so that i can select the file from that by opening that dialog box and select a file and add the path into a text box....

i will be very helpful to one and all if u help me in solving this problem...
Aug 1 '06 #1
4 50705
dctuck
1 New Member
Hi,

I use vb.net, but I think the method will be similar:

You need to add an OpenFileDialog control to your form (from the toolbox), then call the OpenFileDialog1.ShowDialog method to display it. The filename, including path, which the user has selected will be OpenFileDialog1.FileName, so you would just set your textbox.Text property to that.

You should also check that the user hasn't cancelled the dialog - the .ShowDialog method returns True if a file is selected (i.e. user clicked OK or double clicked filename), or False if they cancelled.

In VB, you would do this as

Expand|Select|Wrap|Line Numbers
  1. If OpenFileDialog1.ShowDialog = True Then
  2.     myTextBox.Text = OpenFileDialog1.FileName
  3. End If
  4.  
Hope this helps,

Daniel

hi frnds,

iam shaam working on c#.net. i want the way how to open an open dialog box so that i can select the file from that by opening that dialog box and select a file and add the path into a text box....

i will be very helpful to one and all if u help me in solving this problem...
Aug 1 '06 #2
dab
3 New Member
I use VB.NET also, but I know a tad C#, so, here goes:



Expand|Select|Wrap|Line Numbers
  1.         private void Form1_Load(object sender, EventArgs e)
  2.         {
  3.             openFileDialog1.Filter = "Text Files .txt|*.txt";
  4.             openFileDialog1.ShowDialog();
  5.  
  6.  
  7.             if (openFileDialog1.FileName != "");
  8.             {
  9.                 textBox1.Text = openFileDialog1.FileName;
  10.  
  11.             }
  12.  
  13.  
  14.  
  15.         }
Aug 3 '06 #3
shaam
11 New Member
thanks a lot for the solution, but i need to open an open dialog box in an asp application.here the openfiledialog option is disabled...
Aug 7 '06 #4
sangitadeori
2 New Member
hi frnds,

iam shaam working on c#.net. i want the way how to open an open dialog box so that i can select the file from that by opening that dialog box and select a file and add the path into a text box....

i will be very helpful to one and all if u help me in solving this problem...
Hai
Shaam

I am Sangita Deori,working on C#.Net as a GIS developer in DAKC.I have also gone through your problem,the solution to your problem is very simple.M sendin a piece of code for atleast your programe to run.
You need to take a OpenDialog box ,text box(now for the properties for the text box do text= multiline, scrollbar as both or vartical anything you could take) and a button .

Now on button click write the following code.Believe me it will run


private void button1_Click(object sender, EventArgs e)
{
openFileDialog1.ShowDialog();
string s = openFileDialog1.FileName;
MessageBox.Show(s);
StringReader sr = new StringReader(s);
string t1 = sr.ReadToEnd();
textBox1.AppendText(t1);
textBox1.AppendText("***********************"); /* for seperating b/w paths,you could commecnt it too*/
sr.Close();
}
Apr 18 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Visual Systems AB \(Martin Arvidsson\) | last post by:
Hi! Is there a way to customize a dialogbox. I want buttons with the text: Yes, No, Yes to all, No to all.. Also a dialogbox with a CheckBox. Regards Martin
1
by: foreman | last post by:
Hello Everybody: I am trying out DialogBox, and I have been trying to press the OK Button on the dialogbox hoping I can receive the OK DialogResult to Main Form. Below is my OK button click...
0
by: John Marco | last post by:
I'm working on adding some dialogs to a DirectX app that I've been working on. The DirectX app by itself works fine, but when I try to define a DialogBox and call the DialogBox function, I get the...
3
by: majid | last post by:
When i show a webform as a dialogbox using showModalDialog script any postback event in dialogbox cause a new window pops up . How can i control the postback?
4
by: Fendi Baba | last post by:
I am creating a simple project information database. In the project information form 1 have two subforms. one contains organization involved - many organzation can be involved - and another list of...
9
by: joemo2003 | last post by:
Please help. I created a custom dialogbox name "DialogBox". What i want is input values to the dialogbox, and those values appear on a textbox in Visio. After i creat the textbox and the dialogbox,...
5
by: joemo2003 | last post by:
In excel use "Application.Dialogs(xldialogopen).Show" to open a opendialogbox. Anybody know what is the name for the open dialogbox in Visio? thanks
1
by: PeteOlcott | last post by:
Does anyone know how to make a scalable image on a DialogBox? I am currently using a static Picture Control, can this be adapted to become scalable to the size of the DialogBox?
1
by: duwei | last post by:
I got a example, it GetBkColor from a HDC(the dc get from a DialogBox), but it BkColor always color white, dialogbox default BkColor is color like gray, how can I do to get the correct color for...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.