共用方式為


ButtonBase.ImageAlign 屬性

定義

取得或設定按鈕控制項上影像的對齊方式。

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

屬性值

ContentAlignment

其中一個 ContentAlignment 值。 預設值是 MiddleCenter

例外狀況

所指派的值不是其中一個 ContentAlignment 值。

範例

下列程式碼範例會使用衍生類別, Button 並設定其一些通用屬性。 結果會是一個平面按鈕,其中包含左邊的文字,以及右邊的影像。 此程式碼需要您有一個名為 MyBitMap.bmp 的點陣圖影像儲存在 C:\Graphics 目錄中,且包含命名空間的 System.Drawing 參考。

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

適用於

另請參閱