This documentation is archived and is not being maintained.

Control.ControlCollection.SetChildIndex Method

Sets the index of the specified child control in the collection to the specified index value.

[Visual Basic]
Public Sub SetChildIndex( _
   ByVal child As Control, _
   ByVal newIndex As Integer _
public void SetChildIndex(
 Control child,
 int newIndex
public: void SetChildIndex(
 Control* child,
 int newIndex
public function SetChildIndex(
   child : Control,
 newIndex : int


The child Control to search for.
The new index value of the control.


Exception Type Condition
ArgumentException The child control is not in the Control.ControlCollection.


When SetChildIndex is called, the Control referred to by the child parameter is moved to the position specified by newIndex and the other Control references in the Control.ControlCollection are reordered to accommodate the move. The control with an index value of zero is at the top of the z-order, and higher numbers are closer to the bottom.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

Control.ControlCollection Class | Control.ControlCollection Members | System.Windows.Forms Namespace | GetChildIndex