在C#中两个窗体的跳转(.show) 具体怎么写 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 //这是第一个窗体的一个按钮单击事件 private void button1_Click(object sender, EventArgs e) { Form2 frm = new Form2(); frm.Show(this); //this必须写,传递当前窗体 this.Visible = false;} //这是第二个窗体的一个按钮单击事件 private void button1_Click(object sender, EventArgs e) { Form1 frm = (Form1)this.Owner; //注意是Owner,不是Owner() frm.Visible = true; this.Close(); } 还可使用委托使用委托实现两个窗体的交互:// 主窗体中FromB frm = new FromB("Hello A");frm.onReportProgress = new DoReportProgress(OnReportProgress);frm.ShowDialog(); // 显示窗体private void OnReportProgress(string str){ MessageBox.Show(str);}// 子窗体public delegate void DoReportProgress(string strInfor);public DoReportProgress onReportProgress;public FromB(string str) // 传入父窗体的值{ InitializeComponent(); MessageBox.Show(str);}public void button1(){ if(onReportProgress!=null) onReportProgress("Hello B"); // 调用委托将值返回给父窗体} string.Empty 与 "" 之前有什么区别 listviewEx使用的问题 有这么一种软件吗? .NET(XP SP2)下还有无办法实现IP的隐藏或是更改IP头从而与网页交互?高手请进! DataSet 系列化 问题 关于内存管理问题~ 一个困惑的简单问题,大家来看看啊!!!!!!!!!! 那位有以下几本书的中文电子版,谢谢! C#中是否可以调用C中的.h文件? 请问Sql Server 7.0在哪下载? 求ACCESS备份与还原的源码最好有实例 linkbutton 无效
//这是第一个窗体的一个按钮单击事件
private void button1_Click(object sender, EventArgs e)
{
Form2 frm = new Form2();
frm.Show(this); //this必须写,传递当前窗体
this.Visible = false;}
//这是第二个窗体的一个按钮单击事件
private void button1_Click(object sender, EventArgs e)
{
Form1 frm = (Form1)this.Owner; //注意是Owner,不是Owner()
frm.Visible = true;
this.Close();
}
使用委托实现两个窗体的交互:
// 主窗体中
FromB frm = new FromB("Hello A");
frm.onReportProgress = new DoReportProgress(OnReportProgress);
frm.ShowDialog(); // 显示窗体
private void OnReportProgress(string str)
{
MessageBox.Show(str);
}
// 子窗体
public delegate void DoReportProgress(string strInfor);
public DoReportProgress onReportProgress;
public FromB(string str) // 传入父窗体的值
{
InitializeComponent();
MessageBox.Show(str);
}
public void button1()
{
if(onReportProgress!=null)
onReportProgress("Hello B"); // 调用委托将值返回给父窗体
}