新的项目是一个Winform(MDI)的,中间会用到弹出模态子窗体修改完后回到父窗体.由于在使用了模态窗体会导致在状态栏有很多窗体的.这样做很不雅观.因此对弹出模态窗体进行了一个变相的解决.
这里不再具体的解释,看测试代码吧!希望对新手有所帮助.
1//Form2(子窗体)
2public event dgSample CallWrite;
3public delegate void dgSample(string name);
4private void button1_Click(object sender, System.EventArgs e)
5{
6 CallWrite(textBox1.Text.Trim());
7 this.Close();
8}
9
10//Form1(父窗体)
11private void button1_Click(object sender, System.EventArgs e)
12{
13 Form2 frm = new Form2();
14 frm.CallWrite += new SampleWindows3.Form2.dgSample(WriteText);
15 frm.Show();
16}
17
18private void WriteText(string name)
19{
20 textBox1.Text = name;
21}
2public event dgSample CallWrite;
3public delegate void dgSample(string name);
4private void button1_Click(object sender, System.EventArgs e)
5{
6 CallWrite(textBox1.Text.Trim());
7 this.Close();
8}
9
10//Form1(父窗体)
11private void button1_Click(object sender, System.EventArgs e)
12{
13 Form2 frm = new Form2();
14 frm.CallWrite += new SampleWindows3.Form2.dgSample(WriteText);
15 frm.Show();
16}
17
18private void WriteText(string name)
19{
20 textBox1.Text = name;
21}