在下面这个事件中加以判断 public event EventHandler HandleCreated
我要在一个button的click事件下判断它,怎么写呢?
If you are use the MDI windows, have a look at my last answer in this link: http://expert.csdn.net/Expert/TopicView3.asp?id=1231140思路是这样,判断MDI Parent的MdiChildren,看看是否已经有这个实例了. 代码如下,假设我们想打开一个Form2,这段代码是在MDI Parent Form中:foreach(Form f in this.MdiChildren) { if (f.GetType() == typeof(Form2)) f.Show(); return; }Form2 f2 = new Form2(); f2.MdiParent = this; f2.Show();For more
修改窗体的构造函数,如下: public class Form1 : System.Windows.Forms.Form { public static int openNum=0;//静态变量,表示目前打开的Form2的数量 public Form1() { Form1.openNum++;//改动 InitializeComponent(); } } 这样在你使用Form1前先判断Form1.openNum>1来决定自程序启动以来窗体是否第一次打开
form1 newform = new form1() ;
newform .MdiParent=this;
newform.Show();
怎样判断它第一次被加载呢?
public event EventHandler HandleCreated
http://expert.csdn.net/Expert/TopicView3.asp?id=1231140思路是这样,判断MDI Parent的MdiChildren,看看是否已经有这个实例了.
代码如下,假设我们想打开一个Form2,这段代码是在MDI Parent Form中:foreach(Form f in this.MdiChildren)
{
if (f.GetType() == typeof(Form2)) f.Show();
return;
}Form2 f2 = new Form2();
f2.MdiParent = this;
f2.Show();For more
public class Form1 : System.Windows.Forms.Form
{
public static int openNum=0;//静态变量,表示目前打开的Form2的数量
public Form1()
{
Form1.openNum++;//改动
InitializeComponent();
}
}
这样在你使用Form1前先判断Form1.openNum>1来决定自程序启动以来窗体是否第一次打开