winform 控件置頂

我們知道要把一個控件置頂的話一般有兩種方法,一種是直接在界面裏選中控件-》右鍵-》置於頂層

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


這裏主要介紹第三種方法SetChildIndex:

this.Controls.SetChildIndex(label1, 0);


爲了獲取控件當前的索引,可以使用GetChildIndex方法。

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



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章