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

傳回

Int32

以零起始的索引值,表示控制項集合中指定的子控制項位置。

例外狀況

child 控制項不在 Control.ControlCollection 中。

備註

索引值為零的控制項位於迭置順序的頂端,而較高的數位較接近底部。

另請參閱

適用於

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

true 表示如果 child 參數中指定的 Control 不是 Control.ControlCollection 中的控制項,則擲回例外狀況,否則為 false

傳回

Int32

以零起始的索引值,表示控制項集合中指定的子控制項位置,如果指定的 Control 不在 Control.ControlCollection 中,則為 -1。

例外狀況

childControl 不在 Control.ControlCollection 中,而且 throwException 參數值為 true

備註

索引值為零的控制項位於迭置順序的頂端,而較高的數位較接近底部。 只有在 參數為 時,才會傳回 -1 的 throwException false 傳回值。

另請參閱

適用於