This documentation is archived and is not being maintained.

Control.BringToFront Method

Brings the control to the front of the z-order.

[Visual Basic]
Public Sub BringToFront()
[C#]
public void BringToFront();
[C++]
public: void BringToFront();
[JScript]
public function BringToFront();

Remarks

The control is moved to the front of the z-order. If the control is a child of another control, the child control is moved to the front of the z-order. BringToFront does not make a control a top-level control.

Example

[Visual Basic, C#, C++] The following example ensures that a Label is visible by calling its BringToFront method. This example assumes you have a Form with a Panel named panel1, and a Label named label1.

[Visual Basic] 
Private Sub MakeLabelVisible()
   ' If the panel contains label1, bring it 
   ' to the front to make sure it is visible. 
   If panel1.Contains(label1) Then
      label1.BringToFront()
   End If
End Sub

[C#] 
private void MakeLabelVisible()
{
   /* If the panel contains label1, bring it 
   * to the front to make sure it is visible. */
   if(panel1.Contains(label1))
   {
      label1.BringToFront();
   }
}

[C++] 
private:
    void MakeLabelVisible() {
        /* If the panel contains label1, bring it
         * to the front to make sure it is visible. */
        if (panel1->Contains(label1)) {
            label1->BringToFront();
        }
    }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

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 Class | Control Members | System.Windows.Forms Namespace | SendToBack | UpdateZOrder

Show: