Shape.Enabled (Propiedad)
Obtiene o establece un valor que indica si un control de línea o forma puede responder a interacción del usuario.
Espacio de nombres: Microsoft.VisualBasic.PowerPacks
Ensamblado: Microsoft.VisualBasic.PowerPacks.Vs (en Microsoft.VisualBasic.PowerPacks.Vs.dll)
Sintaxis
'Declaración
<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 propiedad
Tipo: Boolean
Es true si el control puede responder a la interacción del usuario; en caso contrario, es false.De manera predeterminada, es true.
Comentarios
Con el Enabled propiedad, puede impedir que las líneas y formas se selecciona en tiempo de ejecución. También puede deshabilitar los controles que no se aplican al estado actual de la aplicación. Por ejemplo, una forma puede deshabilitarse para evitar que el usuario haga clic en él hasta que se cumpla una determinada condición, emula el comportamiento de un botón.
Ejemplos
En el ejemplo siguiente se muestra cómo habilitar y deshabilitar un RectangleShape control en tiempo de ejecución. Este código requiere que haya un Form con una RectangleShape control y un TextBox control en él.
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);
}
}
Seguridad de .NET Framework
- Plena confianza para el llamador inmediato. Un código de confianza parcial no puede utilizar este miembro. Para obtener más información, vea Utilizar bibliotecas de código que no es de plena confianza.
Vea también
Referencia
Microsoft.VisualBasic.PowerPacks (Espacio de nombres)
Otros recursos
Cómo: Dibujar líneas con el control LineShape (Visual Studio)
Cómo: Dibujar formas con los controles OvalShape y RectangleShape (Visual Studio)
Introducción a los controles de líneas y formas (Visual Studio)