Label.BorderStyle Vlastnost

Definice

Získá nebo nastaví styl ohraničení ovládacího prvku.

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

Hodnota vlastnosti

BorderStyle

Jedna z BorderStyle hodnot. Výchozí formát je BorderStyle.None.

Výjimky

Přiřazená hodnota není jednou z BorderStyle hodnot.

Příklady

Následující příklad kódu ukazuje, jak vytvořit Label ovládací prvek, který má trojrozměrné ohraničení a obrázek zobrazený pomocí ImageList a ImageIndex vlastností. Ovládací prvek má také titulek se zadaným měmónickým znakem. Ukázkový kód používá PreferredHeight vlastnosti k PreferredWidth správné velikosti Label ovládacího prvku ve formuláři, na kterém se zobrazí. Tento příklad vyžaduje vytvoření ImageList a pojmenování imageList1 a načtení dvou imagí. Tento příklad také vyžaduje, aby kód byl ve formuláři s přidaným oborem System.Drawing názvů do kódu.

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

Poznámky

Tuto vlastnost můžete použít k přidání ohraničení ovládacího prvku. Tato vlastnost se obvykle používá k odlišení Label jiného ovládacího prvku od Label toho, který zobrazuje stav procesu v aplikaci.

Platí pro

Viz také