Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How do you link two forms together in C# (these are both .cs and are both forms)

Posted on 2003-11-04
4
Medium Priority
?
1,283 Views
Last Modified: 2008-03-03
I would like to know how to  link two forms together (both .cs and both forms)

Well really it's when the user clicks on the button it takes them to another form.
0
Comment
Question by:paulddaw
  • 2
4 Comments
 
LVL 1

Expert Comment

by:andyalmq
ID: 9679179
Lets say the class names of your two forms were Form1 and Form2.  on the click event of the button, you could do

Form2 newForm = new Form2();
newForm.Show();

You may want to define the second form as a member for the first so that you can have a reference to it.  make the class a private member variable in your class:

private Form2 newForm;

and then from your click event add this instead:
newForm = new Form2()
newForm.Show();
0
 

Author Comment

by:paulddaw
ID: 9679654
Thanks
0
 
LVL 19

Expert Comment

by:Fahad Mukhtar
ID: 9680001
Check this:
Communication Between Two Forms
http://www.c-sharpcorner.com/Code/2002/June/CommBetweenForms.asp
0
 
LVL 19

Accepted Solution

by:
Fahad Mukhtar earned 500 total points
ID: 9680060
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Loops Section Overview
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

782 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question