Click here to Skip to main content
15,888,733 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How can i Call a Method in one form to another from in winform App using c#.
Posted
Comments
Menon Santosh 7-Nov-11 8:10am    
define a class and implement the method in that class so that u can call it anywhere
Sam Path 7-Nov-11 8:18am    
k sir thanks..

This is 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
Menon Santosh 7-Nov-11 23:43pm    
nice Solution my +5
Sergey Alexandrovich Kryukov 8-Nov-11 0:01am    
Thank you, Menon.
--SA
Hi Sam Path,
i think that you are beginner for winform application with c#. If yes then you need to refer below links first.

http://msdn.microsoft.com/en-us/library/ms173114.aspx[^]
http://www.dotnetperls.com/public[^]

and then try to understand the give link's issue may be very helpful to you.
http://www.c-sharpcorner.com/Forums/Thread/44599/calling-a-method-from-another-form.aspx[^]
 
Share this answer
 
Comments
Sam Path 7-Nov-11 8:07am    
Ya i am a beginner sir...
check this example
method in form1
C#
public static void ShowMsg()
        {
            MessageBox.Show("Test");
        }

//called in form2
 Form1.ShowMsg();
 
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