Propriedade Shape.Enabled

Obtém ou define um valor que indica se um controle de forma ou linha pode responder à interação do usuário.

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

Sintaxe

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

Valor de propriedade

Tipo: System.Boolean
true Se o controle pode responder à interação do usuário; caso contrário, false. O padrão é true.

Comentários

Com o Enabled propriedade, você pode impedir que linhas e formas selecionado em time de execução. Você também pode desabilitar os controles que não se aplicam ao estado corrente do aplicativo.Por exemplo, uma forma pode ser desabilitado para evitar que o usuário clicar nela até que uma determinada condição seja satisfeita emular o comportamento de um botão.

Exemplos

O exemplo a seguir demonstra como ativar e desabilitar um RectangleShape controle em time de execução. Esse código requer que você tenha um Form com um RectangleShape controle e um TextBox controle sobre ele.

PrivateSub TextBox1_TextChanged(ByVal sender AsObject, _
 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)
    EndIfEndSub
privatevoid 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);
    }
}

Permissões

Consulte também

Referência

Shape Classe

Membros Shape

Namespace Microsoft.VisualBasic.PowerPacks

Outros recursos

Como: Desenhar linhas com o Controlarar de LineShape (Visual Studio)

Como: Desenhar formas com a OvalShape e controles de RectangleShape (Visual Studio)

Introdução à linha e controles de forma (Visual Studio)