事情是這樣的,我做了一個窗體(winform),窗體上有一個panle,當用戶在父窗體上輸入"A"的時候,調出一個窗體,這個子窗體上這樣調用出來的
fr1 f_r=new fr1(this.panel1);
f_r.TopLevel=false;
f_r.Parent=this.panel1;
f_r.Show();當然這個fr1上還要打開另外一個窗體
Panel pl1;
構造函數和代碼如下
public fr1(Panel pl)
{
pl1 = pl;
InitializeComponent();
this.textBox1.GotFocus+=new EventHandler(textBox1_GotFocus);
} private void button1_Click(object sender, EventArgs e)
{
this.Close();
}
private void textBox1_GotFocus(object sender, EventArgs e)
{
Form fr_2 = new Form();
fr_2.Show();
}現在結果是fr_2不管怎樣都退不出來,點擊一個彈出一個,點擊關閉按鈕,寫事件代碼都不行
這個是什么原因呢?
fr1 f_r=new fr1(this.panel1);
f_r.TopLevel=false;
f_r.Parent=this.panel1;
f_r.Show();當然這個fr1上還要打開另外一個窗體
Panel pl1;
構造函數和代碼如下
public fr1(Panel pl)
{
pl1 = pl;
InitializeComponent();
this.textBox1.GotFocus+=new EventHandler(textBox1_GotFocus);
} private void button1_Click(object sender, EventArgs e)
{
this.Close();
}
private void textBox1_GotFocus(object sender, EventArgs e)
{
Form fr_2 = new Form();
fr_2.Show();
}現在結果是fr_2不管怎樣都退不出來,點擊一個彈出一個,點擊關閉按鈕,寫事件代碼都不行
這個是什么原因呢?
建议,更改fr_2弹出的时机和条件
{
Form fr_2 = new Form();
fr_2.Show();
}
1楼正解