Control.BringToFront 方法

定义

将控件带到 Z 顺序的前面。Brings the control to the front of the z-order.

public:
 void BringToFront();
public void BringToFront ();
member this.BringToFront : unit -> unit
Public Sub BringToFront ()

示例

下面的代码示例通过调用其 BringToFront 方法来确保 Label 可见。The following code example ensures that a Label is visible by calling its BringToFront method. 此示例要求具有一个名为 panel1PanelForm 以及一个名为 label1LabelThis example requires that you have a Form with a Panel named panel1, and a Label named label1.

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();
      }
   }
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();
   }
}
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

注解

控件移动到 z 顺序的顶层。The control is moved to the front of the z-order. 如果控件是另一个控件的子控件,则子控件移动到 z 顺序的顶层。If the control is a child of another control, the child control is moved to the front of the z-order. BringToFront 不会将控件设置为顶级控件,并且它不会引发 Paint 事件。BringToFront does not make a control a top-level control, and it does not raise the Paint event.

适用于

另请参阅