Control.ControlCollection.GetChildIndex 方法

定义

检索控件集合内的控件的索引。Retrieves the index of a control within the control collection.

重载

GetChildIndex(Control)

检索控件集合内的指定子控件的索引。Retrieves the index of the specified child control within the control collection.

GetChildIndex(Control, Boolean)

检索控件集合内的指定子控件的索引,并且如果指定控件不在控件集合内,也可能引发异常。Retrieves the index of the specified child control within the control collection, and optionally raises an exception if the specified control is not within the control collection.

GetChildIndex(Control)

检索控件集合内的指定子控件的索引。Retrieves the index of the specified child control within the control collection.

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

要在控件集合中搜索的 ControlThe Control to search for in the control collection.

返回

从零开始的索引值,它表示指定的子控件在控件集合中的位置。A zero-based index value that represents the location of the specified child control within the control collection.

异常

注解

索引值为零的控件位于 z 顺序的顶部,较大的数字更接近底部。The control with an index value of zero is at the top of the z-order, and higher numbers are closer to the bottom.

另请参阅

GetChildIndex(Control, Boolean)

检索控件集合内的指定子控件的索引,并且如果指定控件不在控件集合内,也可能引发异常。Retrieves the index of the specified child control within the control collection, and optionally raises an exception if the specified control is not within the control collection.

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

参数

child
Control

要在控件集合中搜索的 ControlThe Control to search for in the control collection.

throwException
Boolean

如果 child 参数中指定的 Control 不是 Control.ControlCollection 中的控件即引发异常,则为 true;否则为 falsetrue to throw an exception if the Control specified in the child parameter is not a control in the Control.ControlCollection; otherwise, false.

返回

一个从零开始的索引值,它表示指定的子控件在控件集合中的位置;如果在 Control 中未找到指定的 Control.ControlCollection,则索引值为 -1。A zero-based index value that represents the location of the specified child control within the control collection; otherwise -1 if the specified Control is not found in the Control.ControlCollection.

异常

childControl 不在 Control.ControlCollection 中,且 throwException 参数值为 trueThe childControl is not in the Control.ControlCollection, and the throwException parameter value is true.

注解

索引值为零的控件位于 z 顺序的顶部,较大的数字更接近底部。The control with an index value of zero is at the top of the z-order, and higher numbers are closer to the bottom. 仅当 throwException 参数 @no__t 为-1 时,才返回返回值-1。A return value of -1 is returned only when the throwException parameter is false.

另请参阅

适用于