使用C#在Winform App中以一种形式从另一种形式调用方法 [英] Call a Method in one form to another from in winform App using c#

查看:56
本文介绍了使用C#在Winform App中以一种形式从另一种形式调用方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何使用c#在winform App中以一种形式从另一种形式调用方法.

How can i Call a Method in one form to another from in winform App using c#.

推荐答案

这是有关表单协作的常见问题.最可靠的解决方案是在表单类中实现适当的接口.请查看我过去的解决方案以获取更多详细信息:如何以两种形式在列表框之间复制所有项目 [
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


Hi Sam Path,
我认为您是使用C#的Winform应用程序的初学者.如果是,那么您首先需要参考以下链接.

http://msdn.microsoft.com/en-us/library/ms173114.aspx [ ^ ]
http://www.dotnetperls.com/public [ http://www.c-sharpcorner.com/Forums/Thread/44599/calling-a-method-from-another-form.aspx [
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[^]


检查此示例
form1中的方法
check this example
method in form1
public static void ShowMsg()
        {
            MessageBox.Show("Test");
        }

//called in form2
 Form1.ShowMsg();


这篇关于使用C#在Winform App中以一种形式从另一种形式调用方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆