Shape.BringToFront Method

Brings a line or shape control to the front of the z-order.

Namespace:  Microsoft.VisualBasic.PowerPacks
Assembly:  Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)

Syntax

'Declaration
Public Sub BringToFront
public void BringToFront()
public:
void BringToFront()
member BringToFront : unit -> unit
public function BringToFront()

Remarks

The BringToFront method can be used to position a LineShape, OvalShape, or RectangleShape control in front of all other line and shape controls in a given container. It does not position the control in front of other types of controls in the container; graphics drawn by using line and shape controls always appear behind the other controls.

Examples

The following example demonstrates how to use the BringToFront method to change the z-order of shapes at run time. This example requires that you have a RectangleShape control named RectangleShape1 and an OvalShape control named OvalShape1 on a form. For best results, make the controls different colors and make sure that they overlap each other.

Private Sub Shapes_Click(
    ByVal sender As System.Object, 
    ByVal e As System.EventArgs
  ) Handles RectangleShape1.Click, OvalShape1.Click

    ' Bring the control that was clicked to the top of the z-order.
    sender.BringToFront()
End Sub
private void Shapes_Click(System.Object sender, System.EventArgs e)
{
    // Bring the control that was clicked to the top of the z-order.
    ((Shape)sender).BringToFront();
}

.NET Framework Security

See Also

Reference

Shape Class

Microsoft.VisualBasic.PowerPacks Namespace

Other Resources

How to: Draw Lines with the LineShape Control (Visual Studio)

How to: Draw Shapes with the OvalShape and RectangleShape Controls (Visual Studio)

Introduction to the Line and Shape Controls (Visual Studio)