ButtonState ButtonState ButtonState ButtonState Enum


指定按鈕的外觀。Specifies the appearance of a button.

此列舉具有 FlagsAttribute 個屬性允許以位元方式合併其成員值。

public enum class ButtonState
public enum ButtonState
type ButtonState = 
Public Enum ButtonState


All All All All 18176

設定除了 Normal 以外的旗標。All flags except Normal are set.

Checked Checked Checked Checked 1024

按鈕的外觀顯示已選取或鎖存。The button has a checked or latched appearance. 使用這個外觀以顯示已經按了切換按鈕。Use this appearance to show that a toggle button has been pressed.

Flat Flat Flat Flat 16384

按鈕的外觀為平面二維。The button has a flat, two-dimensional appearance.

Inactive Inactive Inactive Inactive 256

按鈕為非現用中 (灰色)。The button is inactive (grayed).

Normal Normal Normal Normal 0

按鈕的外觀為一般 (3D)。The button has its normal appearance (three-dimensional).

Pushed Pushed Pushed Pushed 512

按鈕顯示已經按下。The button appears pressed.


在此範例中, 您會ButtonState使用列舉做為方法DrawButton的參數, button1以指定的狀態。In this example, you use the ButtonState enumeration as a parameter to the method DrawButton to specify the state of button1. 若要執行範例, 請建立兩個button1按鈕button2: 和。To run the example, create two buttons, button1 and button2. 然後以範例button2_Click程式碼取代方法。Then replace the button2_Click method with the example code. 按一下button2以重button1繪並將其狀態Flat變更為。Click button2 to redraw button1 and change its state to Flat.

void button2_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
   // Draws a flat button on button1.
   ControlPaint::DrawButton( System::Drawing::Graphics::FromHwnd( button1->Handle ), 0, 0, button1->Width, button1->Height, ButtonState::Flat );

private void Button2_Click(object sender, System.EventArgs e)
    // Draws a flat button on button1.
        System.Drawing.Graphics.FromHwnd(_button1.Handle), 0, 0, 
        _button1.Width, _button1.Height,

Private Sub button2_Click(sender As Object, e As System.EventArgs)
    ' Draws a flat button on button1.
    ControlPaint.DrawButton(System.Drawing.Graphics.FromHwnd(button1.Handle), 0, 0, button1.Width, button1.Height, ButtonState.Flat)
End Sub


此列舉類型代表按鈕的不同狀態。This enumeration represents the different states of a button. 預設狀態為NormalThe default state is Normal.