Export (0) Print
Expand All

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)

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

Property Value

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

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.

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

Show:
© 2014 Microsoft