WINFORM用户控件与主窗体间操作问题请教。
有一个主窗体文件:Form1.cs
中有移除flowLayoutPanel1中控件方法:
public void RemoveControl(Control ctrl)
{
flowLayoutPanel1.Controls.Remove(ctrl);
flowLayoutPanel1.Refresh();
}
该主体窗体button1事件执行以上移除方法正常。
请教在
另一个用户控件文件:UserControl1.cs(该控件包含在Form1中)
有一个groupBox1(这里有其他内容)和button1,点击button1移除事件如下:
//移除
public void button1_Click(object sender, EventArgs e)
{
//执行移除主窗体Form1,RemoveControl,移除当前groupBox1
}