ComboBoxStyle 枚举
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
指定 ComboBox 样式。
public enum class ComboBoxStyle
public enum ComboBoxStyle
type ComboBoxStyle =
Public Enum ComboBoxStyle
- 继承
字段
DropDown | 1 | 通过单击下箭头指定显示列表,并指定文本部分可编辑。 这表示用户可以输入新的值,而不仅限于选择列表中现有的值。 使用此设置时,Append 的 AutoCompleteMode 值的作用与 SuggestAppend 值相同。 这是默认样式。 |
DropDownList | 2 | 通过单击下箭头指定显示列表,并指定文本部分不可编辑。 这表示用户不能输入新的值。 只能选择列表中已有的值。 只有在 AutoCompleteMode 为 Suggest 或 SuggestAppend 时才会显示列表。 |
Simple | 0 | 指定列表始终可见,并指定文本部分可编辑。 这表示用户可以输入新的值,而不仅限于选择列表中现有的值。 |
示例
下面的代码示例演示如何通过将属性设置为ComboBox.DropDownStyleComboBoxStyle值来初始化ComboBox控件。
// 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->IntegralHeight = false;
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.
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.IntegralHeight = false;
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.
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.IntegralHeight = False
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
注解
该 DropDownStyle 属性指定列表是始终显示还是列表是否显示在下拉列表中。 该 DropDownStyle 属性还指定是否可以编辑文本部分。