有这么一个语句
             Form2 test2 = new Form2();  //定义一个winform
          
            //把winform加到Panel中
            this.splitContainer1.Panel2.Controls.Add(test2);            //设置winform的索引值
            this.splitContainer1.Panel2.Controls.SetChildIndex(test2, 0);            
   为什么要设置索引值了?只能用 0,我用 1,2,3,4,可以吗?

解决方案 »

  1.   

    调用 SetChildIndex 时,将把 child 参数所引用的 Control 移动到 newIndex 指定的位置,并将重新调整 Control.ControlCollection 中的其他 Control 引用的顺序以适应此次移动。索引值为零的控件位于 Z-顺序的顶部,数字越大距底部越近。
      

  2.   

    有些时候需要那个控件显示在最顶上,就设置索引值
    就像在IDE里右键单击控件,里面有菜单:“置于顶层”、“置于底层”
      

  3.   

    你可以指定其它的值,但应小于Controls.Count,当设置为0时控件置于最上层,设置为其它值则会被覆盖.