ButtonBase.TextAlign Vlastnost

Definice

Získá nebo nastaví zarovnání textu v ovládacím prvku tlačítko.

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

Hodnota vlastnosti

Jedna z ContentAlignment hodnot. Výchozí formát je MiddleCenter.

Výjimky

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

Příklady

Následující příklad kódu používá odvozenou třídu Button a nastaví některé z jejích společných vlastností. Výsledkem bude ploché tlačítko s textem vlevo a obrázkem vpravo. Tento kód vyžaduje, abyste měli rastrový obrázek s názvem MyBitMap.bmp uložený v C:\Graphics adresáři a aby byl zahrnut odkaz na System.Drawing obor názvů.

private:
   void SetMyButtonProperties()
   {
      // Assign an image to the button.
      button1->Image = Image::FromFile( "C:\\Graphics\\MyBitmap.bmp" );
      // Align the image and text on the button.
      button1->ImageAlign = ContentAlignment::MiddleRight;
      button1->TextAlign = ContentAlignment::MiddleLeft;
      // Give the button a flat appearance.
      button1->FlatStyle = FlatStyle::Flat;
   }
private void SetMyButtonProperties()
 {
    // Assign an image to the button.
    button1.Image = Image.FromFile("C:\\Graphics\\MyBitmap.bmp");
    // Align the image and text on the button.
    button1.ImageAlign = ContentAlignment.MiddleRight;    
    button1.TextAlign = ContentAlignment.MiddleLeft;
    // Give the button a flat appearance.
    button1.FlatStyle = FlatStyle.Flat;
 }
Private Sub SetMyButtonProperties()
    ' Assign an image to the button.
    button1.Image = Image.FromFile("C:\Graphics\MyBitmap.bmp")
    ' Align the image and text on the button.
    button1.ImageAlign = ContentAlignment.MiddleRight
    button1.TextAlign = ContentAlignment.MiddleLeft
    ' Give the button a flat appearance.
    button1.FlatStyle = FlatStyle.Flat
End Sub

Platí pro

Viz také