以下为部分代码.点击菜单触发下面的事件.
public void menu_click(object sender, System.EventArgs e)
{
string itemname,windowname;
itemname=((MenuItem)sender).Text.ToString();
windowname=this.checkwindowname(itemname);
if (this.checkChildFrmExist("windowname") == true)
{
  return;
}Form form = null;
string strtype="grm."+windowname;
Type type = Type.GetType(strtype);
form = (Form) Activator.CreateInstance(type);
//form.MdiParent = this;
form.Text=itemname;
form.Show();
}
第一个问题:当我把注释行取消注释后,为什么打开的窗口就不可见,就象隐藏了一样.在父窗口的菜单上可以看到该窗口.
第二个问题:c#中数组是否一定要先分配空间大小?能否象PB那样动态的往数组中加数据,不用先分配空间大小.

解决方案 »

  1.   

    第一个问题:你使用的事不是Mdi窗体,可以参考窗体属性一节。
    http://blog.csdn.net/zhzuo/archive/2006/05/05/708941.aspx
    第二个问题:
    使用ArrayList类代替数组。
      

  2.   

    你MainForm里没有设置MDI吧你用ArrayList不就OK了
      

  3.   

    我在MAINFORM里设置了IsMdiContainer=true,不知道还要在哪里设置?
    子窗体要设置什么属性吗?
      

  4.   

    新的Form打开时,并不会默认为Mdi的子窗体。
    并非不可见,而是被MDI窗体挡住了,可使用Form.BrindToFront方法