我们知道要把一个控件置顶的话一般有两种方法,一种是直接在界面里选中控件-》右键-》置于顶层

另外一种是在界面初始化的时候使用BringToFront方法。

这里主要介绍第三种方法SetChildIndex:

this.Controls.SetChildIndex(label1, 0);

为了获取控件当前的索引,可以使用GetChildIndex方法。

int nZorder = this.Controls.GetChildIndex(label1, true);