第一个窗体关闭打开第二个窗体
using System;using System.Collections.Generic;
using System.Windows.Forms;
namespace tree
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form2());//先启动2号窗体
}
}
}
************************************************************
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace tree
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
Form1 f1 = new Form1(this);//实例1号窗体,那里面的this有用什么用呢?
f1.ShowDialog(this);//这个地方什么要用ShowDialog,为什么要用Show(this)就不行呢?
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace tree
{
public partial class Form1 : Form
{
Form2 f2;
public Form1(Form2 f2)
{
this.f2 = f2;//这样有什么用处呢?
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
this.Close();
}
private void button2_Click(object sender, EventArgs e)
{
this.textBox1.Clear();
this.textBox2.Clear();
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
f2.Show();
this.Close();
}
}
}
...全文
相关推荐
Winform通过一个窗体的时间打开另外一个窗体,并执行一个事件,返回结果到第一个窗体
Winform 在一个窗体时间里面打开另外一个窗体,并等到第二个窗体事件执行成功以后,返回执行结果,类似于客户端和服务端通信
jQuery子窗体取得父窗体元素的方法
主要介绍了jQuery子窗体取得父窗体元素的方法,涉及jQuery窗体元素操作的相关技巧,非常具有实用价值,需要的朋友可以参考下
C#.net窗体与窗体之间传值(原代码+文档)
C#.net窗体与窗体之间传值(原代码+文档),可以直接运行看到效果,决不忽悠。
单件实现winform多文档窗体的单开(2.0)
通过单件实现winform多文档窗体的单开
C#窗体之间麻烦的传值
实现了窗体之间麻烦的传值效果,折腾我好一阵儿呢


