-
October 3rd, 2010, 07:50 AM
#1
Send data from one Win form to another
Hi,
I made a secondary form named Form2 for my application in which the user can specify a Picture, Color and Text.
Now, on this Form2, after the user presses OK button, I want to send the the particulars to Form 1 and open it up.
For eg: If the user sets the color=Red, Picture=Img.gif, Text=Hi on Form2,
then the TextBox on Form1 should display Hi in red color and a picture in the PicBox in Form1.
How is the data sent form one form to another?
-
October 3rd, 2010, 12:59 PM
#2
Re: Send data from one Win form to another
See the documentation for System.Windows.Forms.OpenFileDialog (http://msdn.microsoft.com/en-us/libr...iledialog.aspx). A file dialog is used in the way you describe. It is instantiated, displayed, the user performs some action and the result is retrieved from the dialog by the calling code using public properties of the dialog. Make picture, colour and text public properties on Form2. Set them appropriately in the OK handler and then read them from Form1.
-
October 3rd, 2010, 07:55 PM
#3
Re: Send data from one Win form to another
Do you want to do this the simplest way or would you like an approach that will carry forward to WPF?
-
October 3rd, 2010, 11:06 PM
#4
Re: Send data from one Win form to another
Arjay, can you provide a working example, or a link to one?
This is still something I haven't mastered.
-
October 3rd, 2010, 11:15 PM
#5
Re: Send data from one Win form to another
Originally Posted by CodeGuru12
Arjay, can you provide a working example, or a link to one?
This is still something I haven't mastered.
Which approach are you looking for?
-
October 3rd, 2010, 11:23 PM
#6
Re: Send data from one Win form to another
I guess examples of proper ways to share data between forms in a winforms application.
I've seen people provide solutions, but no real world examples.
-
October 3rd, 2010, 11:23 PM
#7
Re: Send data from one Win form to another
Can't edit my post. .. but wanted to also say Thanks!
-
October 4th, 2010, 04:16 PM
#8
Re: Send data from one Win form to another
I think the OP wanted to know how to pass data from form to form, not a OpenFileDialog.
Here is a link with 4 methods:
http://www.codeproject.com/KB/cs/pas...een_forms.aspx
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
|