当前位置:编程学习 > C#/ASP.NET >>

关于控件调用SetChildIndex 方法设置层次问题

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

我的理解的是设置控件索引为0时就会将控件置顶,那如果我连接几个控件设置索引为0,如:
this.Controls.SetChildIndex(this.txtName,0);
this.Controls.SetChildIndex(this.cmdOk,0);
this.Controls.SetChildIndex(this.cmdCancel,0);
this.Controls.SetChildIndex(this.dgvResu,0);

以这样的顺序排列下来,哪个控件是最置顶的,还是一样的?

还有,MSDN上的这句话是什么意思?"索引值为零的控件位于 Z-顺序的顶部," --------------------编程问答-------------------- this.Controls.SetChildIndex(this.txtName,0);
this.Controls.SetChildIndex(this.cmdOk,0);
this.Controls.SetChildIndex(this.cmdCancel,0);
this.Controls.SetChildIndex(this.dgvResu,0);

以这样的顺序排列下来,哪个控件是最置顶的,还是一样的? --------------------编程问答-------------------- 最后一个调用SetChildIndex的控件在顶部.
先前的虽然在调用后也是在顶部,但是后面其他控件调用SetChildIndex的时候,
它就被往后面"调整"了.
你的例子里, 最后dgvResu在顶部
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,