ButtonBase.ImageAlign Właściwość

Definicja

Pobiera lub ustawia wyrównanie obrazu w kontrolce przycisku.

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

Wartość właściwości

ContentAlignment

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

Wyjątki

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

Przykłady

W poniższym przykładzie kodu użyto klasy Button pochodnej i ustawiono niektóre jej typowe właściwości. Wynikiem będzie płaski przycisk z tekstem po lewej stronie i obrazem po prawej stronie. Ten kod wymaga obrazu mapy bitowej o nazwie przechowywanej MyBitMap.bmp 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ż