Label.BorderStyle Label.BorderStyle Label.BorderStyle Label.BorderStyle Property

Definición

Obtiene o establece el estilo de borde del control.Gets or sets the border style for the control.

public:
 virtual property System::Windows::Forms::BorderStyle BorderStyle { System::Windows::Forms::BorderStyle get(); void set(System::Windows::Forms::BorderStyle value); };
public virtual System.Windows.Forms.BorderStyle BorderStyle { get; set; }
member this.BorderStyle : System.Windows.Forms.BorderStyle with get, set
Public Overridable Property BorderStyle As BorderStyle

Valor de propiedad

Uno de los valores de BorderStyle.One of the BorderStyle values. De manera predeterminada, es BorderStyle.None.The default is BorderStyle.None.

Excepciones

El valor asignado no es uno de los valores de BorderStyle.The value assigned is not one of the BorderStyle values.

Ejemplos

En el ejemplo de código siguiente se muestra cómo Label crear un control que tiene un borde tridimensional y una imagen que se muestra ImageList utilizando ImageIndex las propiedades y.The following code example demonstrates how to create a Label control that has a three-dimensional border and an image displayed using the ImageList and ImageIndex properties. El control también tiene un título con un carácter mnemotécnico especificado.The control also has a caption with a mnemonic character specified. El código de ejemplo utiliza PreferredHeight las PreferredWidth propiedades y para ajustar correctamente Label el tamaño del control en el formulario en el que se muestra.The example code uses the PreferredHeight and PreferredWidth properties to properly size the Label control on the form on which it is displayed. En este ejemplo se requiere ImageList que se haya creado y denominado imagelist1 y que haya cargado dos imágenes.This example requires that an ImageList has been created and named imageList1 and that it has loaded two images. En el ejemplo también se requiere que el código esté dentro de un formulario System.Drawing que tenga el espacio de nombres agregado a su código.The example also requires that the code is within a form that has the System.Drawing namespace added to its code.

public:
   void CreateMyLabel()
   {
      // Create an instance of a Label.
      Label^ label1 = gcnew Label;
      
      // Set the border to a three-dimensional border.
      label1->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
      // Set the ImageList to use for displaying an image.
      label1->ImageList = imageList1;
      // Use the second image in imageList1.
      label1->ImageIndex = 1;
      // Align the image to the top left corner.
      label1->ImageAlign = ContentAlignment::TopLeft;
      
      // Specify that the text can display mnemonic characters.
      label1->UseMnemonic = true;
      // Set the text of the control and specify a mnemonic character.
      label1->Text = "First &Name:";
      
      /* Set the size of the control based on the PreferredHeight and PreferredWidth values. */
      label1->Size = System::Drawing::Size( label1->PreferredWidth, label1->PreferredHeight );
      
      //...Code to add the control to the form...
   }
public void CreateMyLabel()
{
   // Create an instance of a Label.
   Label label1 = new Label();

   // Set the border to a three-dimensional border.
   label1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
   // Set the ImageList to use for displaying an image.
   label1.ImageList = imageList1;
   // Use the second image in imageList1.
   label1.ImageIndex = 1;
   // Align the image to the top left corner.
   label1.ImageAlign = ContentAlignment.TopLeft;

   // Specify that the text can display mnemonic characters.
   label1.UseMnemonic = true;
   // Set the text of the control and specify a mnemonic character.
   label1.Text = "First &Name:";
   
   /* Set the size of the control based on the PreferredHeight and PreferredWidth values. */
   label1.Size = new Size (label1.PreferredWidth, label1.PreferredHeight);

   //...Code to add the control to the form...
}

Public Sub CreateMyLabel()
    ' Create an instance of a Label.
    Dim label1 As New Label()
       
    ' Set the border to a three-dimensional border.
    label1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
    ' Set the ImageList to use for displaying an image.
    label1.ImageList = imageList1
    ' Use the second image in imageList1.
    label1.ImageIndex = 1
    ' Align the image to the top left corner.
    label1.ImageAlign = ContentAlignment.TopLeft
     
    ' Specify that the text can display mnemonic characters.
    label1.UseMnemonic = True
    ' Set the text of the control and specify a mnemonic character.
    label1.Text = "First &Name:"
       
    ' Set the size of the control based on the PreferredHeight and PreferredWidth values. 
    label1.Size = New Size(label1.PreferredWidth, label1.PreferredHeight)

    '...Code to add the control to the form...
End Sub

Comentarios

Puede usar esta propiedad para agregar un borde al control.You can use this property to add a border to the control. Esta propiedad se utiliza normalmente para diferenciar Label un que etiqueta otro control Label de que muestra el estado de un proceso en una aplicación.This property is typically used to differentiate a Label that labels another control from a Label that displays the status of a process in an application.

Se aplica a

Consulte también: