Label.ImageAlign Özellik

Tanım

Denetimde görüntülenen görüntünün hizalamasını alır veya ayarlar.

public:
 property System::Drawing::ContentAlignment ImageAlign { System::Drawing::ContentAlignment get(); void set(System::Drawing::ContentAlignment value); };
public System.Drawing.ContentAlignment ImageAlign { get; set; }
member this.ImageAlign : System.Drawing.ContentAlignment with get, set
Public Property ImageAlign As ContentAlignment

Özellik Değeri

ContentAlignment

Değerlerden ContentAlignment biri. Varsayılan değer: ContentAlignment.MiddleCenter.

Özel durumlar

Atanan değer değerlerden ContentAlignment biri değil.

Örnekler

Aşağıdaki kod örneği, ve özellikleri kullanılarak görüntülenen üç boyutlu kenarlık ve görüntüye sahip bir denetimin ImageList ImageIndex nasıl oluşturulacağını Label gösterir. Denetimin ayrıca, belirtilen bir anımsatıcı karakteri olan bir resim yazısı vardır. Örnek kod, denetimi görüntülendiği formda düzgün boyutlandırmak Label için ve PreferredWidth özelliklerini kullanırPreferredHeight. Bu örnek, bir ImageList oluşturulmuş ve imageList1 adlı bir ve iki görüntü yüklemiş olmasını gerektirir. Örnek ayrıca kodun ad alanının koduna System.Drawing eklendiği bir formda olmasını gerektirir.

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

Açıklamalar

Bu özellik, görüntünün düzgün görüntülendiğinden emin olmak için bir görüntüyü denetimin Label sınırları içinde hizalamanızı sağlar. özelliğini veya ImageList ve ImageIndex özelliklerini kullanarak Image öğesine Label görüntü ekleyebilirsiniz. Denetimde görüntülenen görüntüler, denetim görüntüden büyük veya küçükse, denetimi doldurmak için genişletilemez veya küçültülemez.

Şunlara uygulanır

Ayrıca bkz.