ButtonState 枚举

定义

指定按钮的外观。Specifies the appearance of a button.

此枚举有一个 FlagsAttribute 属性,允许按位组合成员值。

public enum class ButtonState
[System.Flags]
public enum ButtonState
type ButtonState = 
Public Enum ButtonState
继承
ButtonState
属性

字段

All 18176

设置除 Normal 以外的所有标志。All flags except Normal are set.

Checked 1024

该按钮具有选中的或锁存的外观。The button has a checked or latched appearance. 使用此外观可显示已按下切换按钮。Use this appearance to show that a toggle button has been pressed.

Flat 16384

该按钮具有平面的二维外观。The button has a flat, two-dimensional appearance.

Inactive 256

该按钮处于非活动状态(已变灰)。The button is inactive (grayed).

Normal 0

该按钮具有正常的外观(三维)。The button has its normal appearance (three-dimensional).

Pushed 512

该按钮处于按下状态。The button appears pressed.

示例

在此示例中, 使用ButtonState枚举作为方法DrawButton的参数来指定的状态button1In this example, you use the ButtonState enumeration as a parameter to the method DrawButton to specify the state of button1. 若要运行该示例, 请创建两button1button2按钮: 和。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.
    ControlPaint.DrawButton(
        System.Drawing.Graphics.FromHwnd(_button1.Handle), 0, 0, 
        _button1.Width, _button1.Height,
        ButtonState.Flat);
}

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.

适用于

另请参阅