Click here to Skip to main content
15,887,338 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
hay guys. i need code for link my form1 and form2 using c#. pls pls help me.
Posted
Comments
Sergey Alexandrovich Kryukov 20-Dec-11 1:47am    
Any detail?
--SA
Suresh Suthar 20-Dec-11 1:48am    
What do you mean by linking forms? Do you want to open form2 using form1's controls or what?? Please elaborate?
Amal anjula 20-Dec-11 1:48am    
Kooo!

It might be the popular question about form collaboration. The most robust solution is implementation of an appropriate interface in form class. Please see my past solution for more detail: How to copy all the items between listboxes in two forms[^].

—SA
 
Share this answer
 
Comments
Abhinav S 20-Dec-11 1:51am    
5!
Sergey Alexandrovich Kryukov 20-Dec-11 2:03am    
Thank you, Abhinav.
--SA
IF you are looking for passing data between forms then Passing Data between Windows Forms[^] should help you.

You can use delegates to communicate between windows forms[^].
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 20-Dec-11 2:04am    
I do know the last method works, but I have some arguments of the benefits of the interface approach; voted 4. My own opinion, of course.
--SA
I think you are talking about C# winform application. Try these:

Passing Data between Windows Forms[^]

hope it helps :)
 
Share this answer
 
C#
private void button1_Click(object sender, EventArgs e)
        {
            Form  f1 = new Form();
            Form1 f2 = new Form1();
            f1.Close();
            f2.Show();

        }
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900