ComboBoxStyle 枚举

指定 ComboBox 样式。

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

语法

声明
Public Enumeration ComboBoxStyle
用法
Dim instance As ComboBoxStyle
public enum ComboBoxStyle
public enum class ComboBoxStyle
public enum ComboBoxStyle
public enum ComboBoxStyle

成员

  成员名称 说明
由 .NET Compact Framework 支持 DropDown 文本部分可编辑。用户必须单击箭头按钮来显示列表部分。这是默认样式。 
由 .NET Compact Framework 支持 DropDownList 用户不能直接编辑文本部分。用户必须单击箭头按钮来显示列表部分。只有在 AutoCompleteModeSuggestSuggestAppend 时才会显示列表。 
Simple 文本部分可编辑。列表部分总可见。 

备注

DropDownStyle 属性确定用户能否在文本部分中输入新值以及列表部分是否总显示。

Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows CE 平台说明: 默认样式是 DropDownList

示例

下面的代码示例演示如何通过将 ComboBox.DropDownStyle 属性值设置为 ComboBoxStyle 来初始化 ComboBox 控件。

' Declare comboBox1 as a ComboBox.
Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox

' This method initializes the combo box, adding a large string 
' array but limiting the drop-down size to six rows so the combo box
' doesn't cover other controls when it expands.
Private Sub InitializeComboBox()
    Me.ComboBox1 = New System.Windows.Forms.ComboBox
    Dim employees() As String = New String() {"Hamilton, David", _
        "Hensien, Kari", "Hammond, Maria", "Harris, Keith", _
        "Henshaw, Jeff D.", "Hanson, Mark", "Harnpadoungsataya, Sariya", _
        "Harrington, Mark", "Harris, Keith", "Hartwig, Doris", _
        "Harui, Roger", "Hassall, Mark", "Hasselberg, Jonas", _
        "Harnpadoungsataya, Sariya", "Henshaw, Jeff D.", "Henshaw, Jeff D.", _
        "Hensien, Kari", "Harris, Keith", "Henshaw, Jeff D.", _
        "Hensien, Kari", "Hasselberg, Jonas", "Harrington, Mark", _
        "Hedlund, Magnus", "Hay, Jeff", "Heidepriem, Brandon D."}

    ComboBox1.Items.AddRange(employees)
    Me.ComboBox1.Location = New System.Drawing.Point(136, 32)
    Me.ComboBox1.MaxDropDownItems = 5
    Me.ComboBox1.DropDownStyle = ComboBoxStyle.DropDown
    Me.ComboBox1.Name = "ComboBox1"
    Me.ComboBox1.Size = New System.Drawing.Size(136, 81)
    Me.ComboBox1.TabIndex = 0
    Me.Controls.Add(Me.ComboBox1)
End Sub

// Declare comboBox1 as a ComboBox.
internal System.Windows.Forms.ComboBox ComboBox1;

// This method initializes the combo box, adding a large string array
// but limiting the drop-down size to six rows so the combo box doesn't 
// cover other controls when it expands.
private void InitializeComboBox()
{
    this.ComboBox1 = new System.Windows.Forms.ComboBox();
    string[] employees = new string[]{"Hamilton, David", "Hensien, Kari",
            "Hammond, Maria", "Harris, Keith", "Henshaw, Jeff D.", 
            "Hanson, Mark", "Harnpadoungsataya, Sariya", 
            "Harrington, Mark", "Harris, Keith", "Hartwig, Doris", 
            "Harui, Roger", "Hassall, Mark", "Hasselberg, Jonas", 
            "Harnpadoungsataya, Sariya", "Henshaw, Jeff D.", 
            "Henshaw, Jeff D.", "Hensien, Kari", "Harris, Keith", 
            "Henshaw, Jeff D.", "Hensien, Kari", "Hasselberg, Jonas",
            "Harrington, Mark", "Hedlund, Magnus", "Hay, Jeff", 
            "Heidepriem, Brandon D."};

    ComboBox1.Items.AddRange(employees);
    this.ComboBox1.Location = new System.Drawing.Point(136, 32);
    this.ComboBox1.MaxDropDownItems = 5;
    this.ComboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
    this.ComboBox1.Name = "ComboBox1";
    this.ComboBox1.Size = new System.Drawing.Size(136, 81);
    this.ComboBox1.TabIndex = 0;
    this.Controls.Add(this.ComboBox1);
    
    // Associate the event-handling method with the 
    // SelectedIndexChanged event.
    this.ComboBox1.SelectedIndexChanged += 
        new System.EventHandler(ComboBox1_SelectedIndexChanged);
}
   // Declare comboBox1 as a ComboBox.
internal:
   System::Windows::Forms::ComboBox^ ComboBox1;

private:
   // This method initializes the combo box, adding a large string array
   // but limiting the drop-down size to six rows so the combo box doesn't 
   // cover other controls when it expands.
   void InitializeComboBox()
   {
      this->ComboBox1 = gcnew System::Windows::Forms::ComboBox;
      array<String^>^ employees = {"Hamilton, David","Hensien, Kari",
         "Hammond, Maria","Harris, Keith","Henshaw, Jeff D.",
         "Hanson, Mark","Harnpadoungsataya, Sariya",
         "Harrington, Mark","Harris, Keith","Hartwig, Doris",
         "Harui, Roger","Hassall, Mark","Hasselberg, Jonas",
         "Harnpadoungsataya, Sariya","Henshaw, Jeff D.",
         "Henshaw, Jeff D.","Hensien, Kari","Harris, Keith",
         "Henshaw, Jeff D.","Hensien, Kari","Hasselberg, Jonas",
         "Harrington, Mark","Hedlund, Magnus","Hay, Jeff",
         "Heidepriem, Brandon D."};
      ComboBox1->Items->AddRange( employees );
      this->ComboBox1->Location = System::Drawing::Point( 136, 32 );
      this->ComboBox1->MaxDropDownItems = 5;
      this->ComboBox1->DropDownStyle = ComboBoxStyle::DropDownList;
      this->ComboBox1->Name = "ComboBox1";
      this->ComboBox1->Size = System::Drawing::Size( 136, 81 );
      this->ComboBox1->TabIndex = 0;
      this->Controls->Add( this->ComboBox1 );
      
      // Associate the event-handling method with the 
      // SelectedIndexChanged event.
      this->ComboBox1->SelectedIndexChanged +=
         gcnew System::EventHandler( this, &Form1::ComboBox1_SelectedIndexChanged );
   }
// Declare comboBox1 as a ComboBox.
System.Windows.Forms.ComboBox comboBox1;

// This method initializes the combo box, adding a large string array
// but limiting the drop-down size to six rows so the combo box doesn't 
// cover other controls when it expands.
private void InitializeComboBox()
{
    this.comboBox1 = new System.Windows.Forms.ComboBox();
    String employees[] = new String[] { "Hamilton, David", "Hensien, Kari", 
        "Hammond, Maria", "Harris, Keith", "Henshaw, Jeff D.", 
        "Hanson, Mark", "Harnpadoungsataya, Sariya", "Harrington, Mark",
        "Harris, Keith", "Hartwig, Doris", "Harui, Roger", "Hassall, Mark",
        "Hasselberg, Jonas", "Harnpadoungsataya, Sariya", 
        "Henshaw, Jeff D.","Henshaw, Jeff D.", "Hensien, Kari", 
        "Harris, Keith", "Henshaw, Jeff D.", "Hensien, Kari", 
        "Hasselberg, Jonas", "Harrington, Mark", "Hedlund, Magnus", 
        "Hay, Jeff", "Heidepriem, Brandon D." };

    comboBox1.get_Items().AddRange(employees);
    this.comboBox1.set_Location(new System.Drawing.Point(136, 32));
    this.comboBox1.set_MaxDropDownItems(5);
    this.comboBox1.set_DropDownStyle(ComboBoxStyle.DropDownList);
    this.comboBox1.set_Name("comboBox1");
    this.comboBox1.set_Size(new System.Drawing.Size(136, 81));
    this.comboBox1.set_TabIndex(0);
    this.get_Controls().Add(this.comboBox1);
    // Associate the event-handling method with the 
    // SelectedIndexChanged event.
    this.comboBox1.add_SelectedIndexChanged(new System.EventHandler(
        comboBox1_SelectedIndexChanged));
} //InitializeComboBox

平台

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

.NET Compact Framework

受以下版本支持:2.0、1.0

请参见

参考

System.Windows.Forms 命名空间