Export (0) Print
Expand All

Shape.Visible Property

Gets or sets a value indicating whether a line or shape control is displayed.

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

[BrowsableAttribute(true)]
public bool Visible { get; set; }

Property Value

Type: System.Boolean
true if the control is displayed; otherwise, false. The default is true.

The Visible property can be used to make graphics objects created by using a LineShape, OvalShape, or RectangleShape control appear and disappear at run time.

The following example demonstrates how to use the Visible property to switch between two different 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 both controls the same size and position one on top of the other.

private void ShapeVisible_Load(System.Object sender, System.EventArgs e)
{
    // Hide the oval.
    ovalShape1.Visible = false;
}

private void Shapes_Click(System.Object sender, System.EventArgs e)
{
    if (ovalShape1.Visible == true)
    // Hide the oval.
    {
        ovalShape1.Visible = false;
        // Show the rectangle.
        rectangleShape1.Visible = true;
    }
    else
    {
        // Hide the rectangle.
        rectangleShape1.Visible = false;
        // Show the oval.
        ovalShape1.Visible = true;
    }
}

Show:
© 2014 Microsoft