Shape.Enabled-Eigenschaft

Aktualisiert: November 2007

Ruft einen Wert ab, der angibt, ob ein Line- oder Shape-Steuerelement auf Benutzerinteraktionen reagieren kann, oder legt diesen fest.

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

Syntax

<BrowsableAttribute(True)> _
Public Property Enabled As Boolean

Dim instance As Shape
Dim value As Boolean

value = instance.Enabled

instance.Enabled = value
[BrowsableAttribute(true)]
public bool Enabled { get; set; }
[BrowsableAttribute(true)]
public:
property bool Enabled {
    bool get ();
    void set (bool value);
}
public function get Enabled () : boolean
public function set Enabled (value : boolean)

Eigenschaftenwert

Typ: System.Boolean

true, wenn das Steuerelement auf Benutzerinteraktionen reagieren kann, andernfalls false. Die Standardeinstellung ist true.

Hinweise

Mit der Enabled-Eigenschaft können Sie verhindern, dass Linien und Formen zur Laufzeit ausgewählt werden. Sie können zudem Steuerelemente deaktivieren, die im aktuellen Zustand der Anwendung nicht verwendet werden sollen. Eine Form kann beispielsweise deaktiviert werden, sodass ein Benutzer diese erst auswählen kann, wenn eine bestimmte Bedingung erfüllt ist. Auf diese Weise wird das Verhalten einer Schaltfläche emuliert.

Beispiele

Im folgenden Beispiel wird veranschaulicht, wie ein RectangleShape-Steuerelement zur Laufzeit aktiviert und deaktiviert wird. Für diesen Code muss ein Form-Steuerelement mit einem RectangleShape-Steuerelement und einem TextBox-Steuerelement auf diesem vorhanden sein.

Private Sub TextBox1_TextChanged(ByVal sender As Object, _
 ByVal e As System.EventArgs) 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);
    }
}

Berechtigungen

Siehe auch

Referenz

Shape-Klasse

Shape-Member

Microsoft.VisualBasic.PowerPacks-Namespace

Weitere Ressourcen

Gewusst wie: Zeichnen von Linien mit dem LineShape-Steuerelement (Visual Studio)

Gewusst wie: Zeichnen von Formen mit dem OvalShape-Steuerelement und dem RectangleShape-Steuerelement (Visual Studio)

Einführung in das Line-Steuerelement und das Shape-Steuerelement (Visual Studio)