473,396 Members | 1,849 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Passing Data Between Forms

What's the best wat to pass data between two separate forms. For instance,
Form1 invokes Form2 like this:

Form z = new Form2();
z.Show();

How can I pass back strings and boolean values from Form2 to Form1?

Thanks,

Michael C.
Nov 16 '05 #1
2 3656
Micheal,

there are many ways to do this. One of those is

//define form1.
Form pForm1 = new Form();

//during launch of Form 2 do this
Form pForm2 = new Form( pForm1); //pass in constructor.
pForm2.ShowDialog(); or pForm.Show();

//Once when Form2 is displayed, to pass value back to form Set through
properties

example .
mForm1.Mybool = Form2.TestBool;

mForm1 is a member in Form2 which is received in constructor. You can
access public variables and internal variables of Form1 in Form2. The other
ways do is by defining event handlers and delegates.

Shak
"Michael C" <mi*******@optonline.net> wrote in message
news:U4*********************@news4.srv.hcvlny.cv.n et...
What's the best wat to pass data between two separate forms. For instance, Form1 invokes Form2 like this:

Form z = new Form2();
z.Show();

How can I pass back strings and boolean values from Form2 to Form1?

Thanks,

Michael C.

Nov 16 '05 #2
Cool, I was trying to decide if passing the form to the constructor like you
did would be better than using public static variables, etc. I'll use your
method. Thanks!

Michael C.

"Shakir Hussain" <sh**@fakedomain.com> wrote in message
news:uR****************@TK2MSFTNGP09.phx.gbl...
Micheal,

there are many ways to do this. One of those is

//define form1.
Form pForm1 = new Form();

//during launch of Form 2 do this
Form pForm2 = new Form( pForm1); //pass in constructor.
pForm2.ShowDialog(); or pForm.Show();

//Once when Form2 is displayed, to pass value back to form Set through
properties

example .
mForm1.Mybool = Form2.TestBool;

mForm1 is a member in Form2 which is received in constructor. You can
access public variables and internal variables of Form1 in Form2. The other ways do is by defining event handlers and delegates.

Shak
"Michael C" <mi*******@optonline.net> wrote in message
news:U4*********************@news4.srv.hcvlny.cv.n et...
What's the best wat to pass data between two separate forms. For

instance,
Form1 invokes Form2 like this:

Form z = new Form2();
z.Show();

How can I pass back strings and boolean values from Form2 to Form1?

Thanks,

Michael C.


Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Alex Vinokur | last post by:
Various forms of argument passing ================================= C/C++ Performance Tests ======================= Using C/C++ Program Perfometer...
12
by: Kevin Lyons | last post by:
Hello, I am trying to get my select options (courses) passed correctly from the following URL: http://www.dslextreme.com/users/kevinlyons/selectBoxes.html I am having difficulty getting the...
2
by: Richard | last post by:
**** Post for FREE via your newsreader at post.usenet.com **** HI, I am working on a project where I need to input data to a (local) HTML page using multiple form elements, such as text,...
11
by: Johnny | last post by:
I'm a rookie at C# and OO so please don't laugh! I have a form (fclsTaxCalculator) that contains a text box (tboxZipCode) containing a zip code. The user can enter a zip code in the text box and...
8
by: Johnny | last post by:
I'm a rookie at C# and OO so please don't laugh! I have a form (fclsTaxCalculator) that contains a text box (tboxZipCode) containing a zip code. The user can enter a zip code in the text box and...
6
by: Scott Zabolotzky | last post by:
I'm trying to pass a custom object back and forth between forms. This custom object is pulled into the app using an external reference to an assembly DLL that was given to me by a co-worker. A...
5
by: Rod | last post by:
I've written 2 ASP.NET applications (I've worked on one with a team and another by myself). In my ASP.NET pages, when saving data to a backend database I've done it by using the click event of a...
0
by: Eric Sabine | last post by:
OK, I'm trying to further my understanding of threading. The code below I wrote as kind of a primer to myself and maybe a template that I could use in the future. What I tried to do was pass data...
2
by: Carl Heller | last post by:
Working in VS2003, .Net 1.1 I'm working on a project where I compare data between two databases. This is a lengthy process, and very data intensive, so I decided to create a class, and thread...
1
by: SteveDouglas | last post by:
Hi all, I am currently writing an application in VB.NET that has a lot of controls (treeviews/listviews/labels and so forth) that represent "things" that need to be draggable from place to place,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.