Share via


CheckBox.Appearance 属性

获取或设置确定 CheckBox 控件外观的值。

**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)

语法

声明
<LocalizableAttribute(True)> _
Public Property Appearance As Appearance
用法
Dim instance As CheckBox
Dim value As Appearance

value = instance.Appearance

instance.Appearance = value
[LocalizableAttribute(true)] 
public Appearance Appearance { get; set; }
[LocalizableAttribute(true)] 
public:
property Appearance Appearance {
    Appearance get ();
    void set (Appearance value);
}
/** @property */
public Appearance get_Appearance ()

/** @property */
public void set_Appearance (Appearance value)
public function get Appearance () : Appearance

public function set Appearance (value : Appearance)

属性值

Appearance 值之一。默认值为 Normal

异常

异常类型 条件

InvalidEnumArgumentException

分配的值不是 Appearance 值之一。

备注

如果将 Appearance 值设置为 Normal,则 CheckBox 具有典型的外观。如果该值设置为 Button,则 CheckBox 外观显示为一个切换按钮,它可切换为向上或向下状态。

示例

下面的代码示例创建了一个 CheckBox 并对它进行了初始化,为它赋予切换按钮的外观,将 AutoCheck 设置为 false,并将该复选框添加到 Form 中。

Public Sub InstantiateMyCheckBox()
    ' Create and initialize a CheckBox.   
    Dim checkBox1 As New CheckBox()
    
    ' Make the check box control appear as a toggle button.
    checkBox1.Appearance = Appearance.Button
    
    ' Turn off the update of the display on the click of the control.
    checkBox1.AutoCheck = False
    
    ' Add the check box control to the form.
    Controls.Add(checkBox1)
End Sub 'InstantiateMyCheckBox
public void InstantiateMyCheckBox()
 {
    // Create and initialize a CheckBox.   
    CheckBox checkBox1 = new CheckBox(); 
    
    // Make the check box control appear as a toggle button.
    checkBox1.Appearance = Appearance.Button;
 
    // Turn off the update of the display on the click of the control.
    checkBox1.AutoCheck = false;
 
    // Add the check box control to the form.
    Controls.Add(checkBox1);
 }
 
public:
   void InstantiateMyCheckBox()
   {
      // Create and initialize a CheckBox.   
      CheckBox^ checkBox1 = gcnew CheckBox;
      
      // Make the check box control appear as a toggle button.
      checkBox1->Appearance = Appearance::Button;
      
      // Turn off the update of the display on the click of the control.
      checkBox1->AutoCheck = false;
      
      // Add the check box control to the form.
      this->Controls->Add( checkBox1 );
   }
public void InstantiateMyCheckBox()
{
    // Create and initialize a CheckBox.   
    CheckBox checkBox1 = new CheckBox();

    // Make the check box control appear as a toggle button.
    checkBox1.set_Appearance(Appearance.Button);

    // Turn off the update of the display on the click of the control.
    checkBox1.set_AutoCheck(false);

    // Add the check box control to the form.
    get_Controls().Add(checkBox1);
} //InstantiateMyCheckBox
public function InstantiateMyCheckBox()
 {
    // Create and initialize a CheckBox.   
    var checkBox1 : CheckBox = new CheckBox(); 
    
    // Make the check box control appear as a toggle button.
    checkBox1.Appearance = Appearance.Button;
 
    // Turn off the update of the display on the click of the control.
    checkBox1.AutoCheck = false;
 
    // Add the check box control to the form.
    Controls.Add(checkBox1);
 }
 

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

CheckBox 类
CheckBox 成员
System.Windows.Forms 命名空间
Appearance 枚举