共用方式為


ButtonBase.FlatStyle 屬性

定義

它能取得或設定按鈕控制的平面外觀。

public:
 property System::Windows::Forms::FlatStyle FlatStyle { System::Windows::Forms::FlatStyle get(); void set(System::Windows::Forms::FlatStyle value); };
public System.Windows.Forms.FlatStyle FlatStyle { get; set; }
member this.FlatStyle : System.Windows.Forms.FlatStyle with get, set
Public Property FlatStyle As FlatStyle

屬性值

這是其中一項 FlatStyle 價值。 預設值為 Standard

例外狀況

分配的值並非其中之一。FlatStyle

範例

以下程式碼範例使用導出類別, Button 並設定其一些常見屬性。 結果會是一個平面按鈕,左邊有文字,右邊有圖片。 此程式碼要求你在目錄中儲存C:\Graphics一個點MyBitMap.bmp陣圖影像,並且包含對命名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

備註

FlatStyleCheckBox 類別的屬性RadioButtonSystem為 時,使用者作業系統會繪製控制項,檢查對齊則基於 CheckAlignTextAlign 屬性值。 CheckAlign房產價值不會改變,但控制的外觀可能會受到影響。 勾選框會與控制項的左邊或右邊水平對齊(左邊或中間對齊看起來是左邊對齊,右邊則保持不變),且垂直對齊方式與描述文字相同。 例如,若你有一個 CheckBox 屬性值為 CheckAlignContentAlignment的控制點。 MiddleCenter,屬性 TextAlign 值為 ContentAlignment.TopRight,屬性 FlatStyle 值設為 System,勾選框對齊會顯示為 , ContentAlignment.TopLeft 而文字對齊保持不變。

備註

FlatStyle 屬性設定為 FlatStyle.System,則指派給該 Image 屬性的任何影像不會顯示。

適用於

另請參閱