ButtonBase.TextAlign Właściwość

Definicja

Pobiera lub ustawia wyrównanie tekstu w kontrolce przycisku.

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

Wartość właściwości

ContentAlignment

Jedna z ContentAlignment wartości. Wartość domyślna to MiddleCenter.

Wyjątki

Przypisana wartość nie jest jedną z ContentAlignment wartości.

Przykłady

Poniższy przykład kodu używa klasy Button pochodnej i ustawia niektóre z jego typowych właściwości. Wynik będzie płaskim przyciskiem z tekstem po lewej stronie i obrazem po prawej stronie. Ten kod wymaga obrazu mapy bitowej o nazwie MyBitMap.bmp przechowywanej C:\Graphics w katalogu i dołączeniu odwołania do System.Drawing przestrzeni nazw.

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

Dotyczy

Zobacz też