winform间如何触发事件 winform 页面A 打开并传值给 页面B,页面B执行完成后,关闭,并同时将某值传回页面A,并要触发页面A中的某些事件。请问,如何实现这种情况呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Form :-) FormB b = new FormB(); b.SomeProperty = "some value"; //传值给 页面B b.ShowDialog(); //打开 string result = b.SomeResult; //将某值传回页面A RunSomeMethod(result); //触发页面A中的某些事件 B: private string str = ""; public string Str { get { return str; } set { str = value; } } private void button1_Click(object sender, EventArgs e) { str ="Hello,"+str; this.DialogResult = DialogResult.OK;//关闭B }A: string strReturn = ""; private void button2_Click(object sender, EventArgs e) { MessageBox.Show(strReturn); } private void button1_Click(object sender, EventArgs e) { Form3 frm = new Form3(); frm.Str = "123"; if (frm.ShowDialog() == DialogResult.OK) { strReturn = frm.Str; button2_Click(null, null);//调用button2_Click事件 } } 参考这里的文章代码,关于数据传递和事件注册---------------------------------谈基于.net平台windows开发中的模式窗体http://blog.csdn.net/zhzuo/archive/2006/05/05/708941.aspx在.net应用程序中使用用户控件http://blog.csdn.net/zhzuo/archive/2004/11/30/199599.aspx 窗体间的值传递,不用事件,可以看看我的博客http://www.cnblogs.com/virusswb/archive/2008/03/31/1131276.html 关于程序集加载的问题 数据关系问题 求一个小函数的写法 ◆IBatis分页问题◆ 日期控件选择的一点问题,请教? === 新建的DataTable(不是用DataAdapter Fill的),不能更新到数据库,怎样解决?=== 新手问-----如何生成*.exe文件而不用更改与库文件的连接 【求助】关于地磅232接口读数据的技术规范或源码(听说项目是C#开发,所以发这个版 了) GRIDVIEW分页问题 问大家一个问题(UDP)分一定给 WindowsXP关机前效果的逼真模仿 可能需要GDI+的技术 近来看看 一个C#小问题
FormB b = new FormB();
b.SomeProperty = "some value"; //传值给 页面B
b.ShowDialog(); //打开
string result = b.SomeResult; //将某值传回页面A
RunSomeMethod(result); //触发页面A中的某些事件
private string str = ""; public string Str
{
get { return str; }
set { str = value; }
} private void button1_Click(object sender, EventArgs e)
{
str ="Hello,"+str;
this.DialogResult = DialogResult.OK;//关闭B
}A:
string strReturn = ""; private void button2_Click(object sender, EventArgs e)
{
MessageBox.Show(strReturn);
} private void button1_Click(object sender, EventArgs e)
{
Form3 frm = new Form3();
frm.Str = "123";
if (frm.ShowDialog() == DialogResult.OK)
{
strReturn = frm.Str;
button2_Click(null, null);//调用button2_Click事件
}
}
---------------------------------
谈基于.net平台windows开发中的模式窗体
http://blog.csdn.net/zhzuo/archive/2006/05/05/708941.aspx
在.net应用程序中使用用户控件
http://blog.csdn.net/zhzuo/archive/2004/11/30/199599.aspx
http://www.cnblogs.com/virusswb/archive/2008/03/31/1131276.html