Control.ControlCollection.GetChildIndex 方法

定义

检索控件集合内的控件的索引。

重载

GetChildIndex(Control)

检索控件集合内的指定子控件的索引。

GetChildIndex(Control, Boolean)

检索控件集合内的指定子控件的索引,并且如果指定控件不在控件集合内,也可能引发异常。

GetChildIndex(Control)

检索控件集合内的指定子控件的索引。

public:
 int GetChildIndex(System::Windows::Forms::Control ^ child);
public int GetChildIndex (System.Windows.Forms.Control child);
member this.GetChildIndex : System.Windows.Forms.Control -> int
Public Function GetChildIndex (child As Control) As Integer

参数

child
Control

要在控件集合中搜索的 Control

返回

从零开始的索引值,它表示指定的子控件在控件集合中的位置。

例外

child 控件不在 Control.ControlCollection 中。

注解

索引值为零的控件位于 z 顺序的顶部,较高的数字更接近底部。

另请参阅

适用于

GetChildIndex(Control, Boolean)

检索控件集合内的指定子控件的索引,并且如果指定控件不在控件集合内,也可能引发异常。

public:
 int GetChildIndex(System::Windows::Forms::Control ^ child, bool throwException);
public:
 virtual int GetChildIndex(System::Windows::Forms::Control ^ child, bool throwException);
public int GetChildIndex (System.Windows.Forms.Control child, bool throwException);
public virtual int GetChildIndex (System.Windows.Forms.Control child, bool throwException);
member this.GetChildIndex : System.Windows.Forms.Control * bool -> int
abstract member GetChildIndex : System.Windows.Forms.Control * bool -> int
override this.GetChildIndex : System.Windows.Forms.Control * bool -> int
Public Function GetChildIndex (child As Control, throwException As Boolean) As Integer
Public Overridable Function GetChildIndex (child As Control, throwException As Boolean) As Integer

参数

child
Control

要在控件集合中搜索的 Control

throwException
Boolean

如果 child 参数中指定的 Control 不是 Control.ControlCollection 中的控件即引发异常,则为 true;否则为 false

返回

一个从零开始的索引值,它表示指定的子控件在控件集合中的位置;如果在 Control 中未找到指定的 Control.ControlCollection,则索引值为 -1。

例外

childControl 不在 Control.ControlCollection 中,且 throwException 参数值为 true

注解

索引值为零的控件位于 z 顺序的顶部,较高的数字更接近底部。 仅当 参数为 false时,throwException才会返回 -1 的返回值。

另请参阅

适用于