Shape.Enabled Property

Gets or sets a value indicating whether a line or shape control can respond to user interaction.

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

Syntax

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

Property Value

Type: System.Boolean
true if the control can respond to user interaction; otherwise, false. The default is true.

Remarks

With the Enabled property, you can prevent lines and shapes from being selected at run time. You can also disable controls that do not apply to the current state of the application. For example, a shape can be disabled to prevent the user from clicking it until a certain condition is met, emulating the behavior of a button.

Examples

The following example demonstrates how to enable and disable a RectangleShape control at run time. This code requires that you have a Form with a RectangleShape control and a TextBox control on it.

Private Sub TextBox1_TextChanged() Handles TextBox1.TextChanged
    ' If the TextBox contains text, enable the RectangleShape. 
    If TextBox1.Text <> "" Then 
        ' Enable the RectangleShape.
        RectangleShape1.Enabled = True 
        ' Change the BorderColor to the default.
        RectangleShape1.BorderColor = 
            Microsoft.VisualBasic.PowerPacks.Shape.DefaultBorderColor
    Else 
        ' Disable the RectangleShape control.
        RectangleShape1.Enabled = False 
        ' Change the BorderColor to show that the control is disabled
        RectangleShape1.BorderColor = 
            Color.FromKnownColor(KnownColor.InactiveBorder)
    End If 
End Sub
private void textBox1_TextChanged(object sender, System.EventArgs e)
{
    // If the TextBox contains text, enable the RectangleShape. 
    if (textBox1.Text != "")
    // Enable the RectangleShape.
    {
        rectangleShape1.Enabled = true;
        // Change the BorderColor to the default.
        rectangleShape1.BorderColor = Microsoft.VisualBasic.PowerPacks.Shape.DefaultBorderColor;
    }
    else
    {
        // Disable the RectangleShape control.
        rectangleShape1.Enabled = false;
        // Change the BorderColor to show that the control is disabled
        rectangleShape1.BorderColor = Color.FromKnownColor(KnownColor.InactiveBorder);
    }
}

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