次の方法で共有


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)

Syntax

'Declaration
<BrowsableAttribute(True)> _
Public Property Visible As Boolean
[BrowsableAttribute(true)]
public bool Visible { get; set; }
[BrowsableAttribute(true)]
public:
property bool Visible {
    bool get ();
    void set (bool value);
}
[<BrowsableAttribute(true)>]
member Visible : bool with get, set
function get Visible () : boolean 
function set Visible (value : boolean)

Property Value

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

Remarks

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.

Examples

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 Sub ShapeVisible_Load() Handles MyBase.Load
    ' Hide the oval.
    OvalShape1.Visible = False 
End Sub 

Private Sub Shapes_Click() Handles RectangleShape1.Click,
                                   OvalShape1.Click

    If OvalShape1.Visible = True Then 
        ' 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 
    End If 
End Sub
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;
    }
}

.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)