110,568
社区成员
发帖
与我相关
我的任务
分享
using System;
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();
}
}
}