Propriedade Shape.Enabled
Obtém ou define um valor que indica se um controle de forma ou de linha pode responder à interação do usuário.
Namespace: Microsoft.VisualBasic.PowerPacks
Assembly: Microsoft.VisualBasic.PowerPacks.Vs (em Microsoft.VisualBasic.PowerPacks.Vs.dll)
Sintaxe
'Declaração
<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)
Valor de propriedade
Tipo: Boolean
trueSe 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 tempo de execução. Você também pode desativar os controles que não se aplicam ao estado atual do aplicativo. Por exemplo, uma forma pode ser desabilitada para impedir que o usuário clicar nele até que uma determinada condição for atendida, emula o comportamento de um botão.
Exemplos
O exemplo a seguir demonstra como habilitar e desabilitar um RectangleShape controle em tempo de execução. Esse código requer que você tenha um Form com um RectangleShape controle e um TextBox controle sobre ele.
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);
}
}
Segurança do .NET Framework
- Confiança total para o chamador imediato. O membro não pode ser usado por código parcialmente confiável. Para obter mais informações, consulte Usando bibliotecas de código parcialmente confiável.
Consulte também
Referência
Namespace Microsoft.VisualBasic.PowerPacks
Outros recursos
Como desenhar linhas com o controle LineShape (Visual Studio)
Como desenhar formas com os controles OvalShape e RectangleShape (Visual Studio)