ComboBox 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
表示 Windows 组合框控件。
public ref class ComboBox : System::Windows::Forms::ListControl
public class ComboBox : System.Windows.Forms.ListControl
[System.ComponentModel.DefaultBindingProperty("Text")]
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Runtime.InteropServices.ComVisible(true)]
public class ComboBox : System.Windows.Forms.ListControl
[System.ComponentModel.DefaultBindingProperty("Text")]
public class ComboBox : System.Windows.Forms.ListControl
type ComboBox = class
inherit ListControl
[<System.ComponentModel.DefaultBindingProperty("Text")>]
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type ComboBox = class
inherit ListControl
[<System.ComponentModel.DefaultBindingProperty("Text")>]
type ComboBox = class
inherit ListControl
Public Class ComboBox
Inherits ListControl
- 继承
- 派生
- 属性
示例
下面的代码示例是一个完整的应用程序,演示如何使用Add该方法向 a ComboBox添加项、FindString查找项ComboBox的方法以及BeginUpdateEndUpdate有效向 a ComboBox添加大量项的方法。 存储与显示文本不同的值的功能继承自 ListControl。 有关如何使用此功能的示例,请参阅类 ListControl 。
必须添加对 System.Drawing 命名空间 System.Windows.Forms 的引用才能运行此示例。
#using <System.dll>
#using <System.Drawing.dll>
#using <System.Windows.Forms.dll>
using namespace System;
using namespace System::Windows::Forms;
namespace Win32Form1Namespace
{
public ref class Win32Form1: public System::Windows::Forms::Form
{
private:
System::Windows::Forms::Button^ addButton;
System::Windows::Forms::TextBox^ textBox2;
System::Windows::Forms::Button^ addGrandButton;
System::Windows::Forms::ComboBox^ comboBox1;
System::Windows::Forms::Button^ showSelectedButton;
System::Windows::Forms::TextBox^ textBox1;
System::Windows::Forms::Button^ findButton;
System::Windows::Forms::Label ^ label1;
public:
Win32Form1()
{
this->InitializeComponent();
}
private:
void InitializeComponent()
{
this->addButton = gcnew System::Windows::Forms::Button;
this->textBox2 = gcnew System::Windows::Forms::TextBox;
this->addGrandButton = gcnew System::Windows::Forms::Button;
this->comboBox1 = gcnew System::Windows::Forms::ComboBox;
this->showSelectedButton = gcnew System::Windows::Forms::Button;
this->textBox1 = gcnew System::Windows::Forms::TextBox;
this->findButton = gcnew System::Windows::Forms::Button;
this->label1 = gcnew System::Windows::Forms::Label;
this->addButton->Location = System::Drawing::Point( 248, 32 );
this->addButton->Size = System::Drawing::Size( 40, 24 );
this->addButton->TabIndex = 1;
this->addButton->Text = "Add";
this->addButton->Click += gcnew System::EventHandler(
this, &Win32Form1::addButton_Click );
this->textBox2->Location = System::Drawing::Point( 8, 64 );
this->textBox2->Size = System::Drawing::Size( 232, 20 );
this->textBox2->TabIndex = 6;
this->textBox2->Text = "";
this->addGrandButton->Location = System::Drawing::Point( 8, 96 );
this->addGrandButton->Size = System::Drawing::Size( 280, 23 );
this->addGrandButton->TabIndex = 2;
this->addGrandButton->Text = "Add 1, 000 Items";
this->addGrandButton->Click += gcnew System::EventHandler(
this, &Win32Form1::addGrandButton_Click );
this->comboBox1->Anchor = (System::Windows::Forms::AnchorStyles)(
(System::Windows::Forms::AnchorStyles::Bottom | System::Windows::Forms::AnchorStyles::Left) |
System::Windows::Forms::AnchorStyles::Right);
this->comboBox1->DropDownWidth = 280;
array<Object^>^ objectArray = {"Item 1",
"Item 2",
"Item 3",
"Item 4",
"Item 5"};
this->comboBox1->Items->AddRange( objectArray );
this->comboBox1->Location = System::Drawing::Point( 8, 248 );
this->comboBox1->Size = System::Drawing::Size( 280, 21 );
this->comboBox1->TabIndex = 7;
this->showSelectedButton->Location = System::Drawing::Point( 8, 128 );
this->showSelectedButton->Size = System::Drawing::Size( 280, 24 );
this->showSelectedButton->TabIndex = 4;
this->showSelectedButton->Text = "What Item is Selected?";
this->showSelectedButton->Click += gcnew System::EventHandler(
this, &Win32Form1::showSelectedButton_Click );
this->textBox1->Location = System::Drawing::Point( 8, 32 );
this->textBox1->Size = System::Drawing::Size( 232, 20 );
this->textBox1->TabIndex = 5;
this->textBox1->Text = "";
this->findButton->Location = System::Drawing::Point( 248, 64 );
this->findButton->Size = System::Drawing::Size( 40, 24 );
this->findButton->TabIndex = 3;
this->findButton->Text = "Find";
this->findButton->Click += gcnew System::EventHandler(
this, &Win32Form1::findButton_Click );
this->label1->Location = System::Drawing::Point( 8, 224 );
this->label1->Size = System::Drawing::Size( 144, 23 );
this->label1->TabIndex = 0;
this->label1->Text = "Test ComboBox";
this->ClientSize = System::Drawing::Size( 292, 273 );
array<System::Windows::Forms::Control^>^ controlsArray = {this->comboBox1,
this->textBox2,
this->textBox1,
this->showSelectedButton,
this->findButton,
this->addGrandButton,
this->addButton,
this->label1};
this->Controls->AddRange( controlsArray );
this->Text = "ComboBox Sample";
}
void addButton_Click( Object^ sender, System::EventArgs^ e )
{
comboBox1->Items->Add( textBox1->Text );
}
void addGrandButton_Click( Object^ sender, System::EventArgs^ e )
{
comboBox1->BeginUpdate();
for ( int i = 0; i < 1000; i++ )
{
comboBox1->Items->Add( "Item 1 " + i.ToString() );
}
comboBox1->EndUpdate();
}
void findButton_Click( Object^ sender, System::EventArgs^ e )
{
int index = comboBox1->FindString( textBox2->Text );
comboBox1->SelectedIndex = index;
}
void showSelectedButton_Click( Object^ sender, System::EventArgs^ e )
{
int selectedIndex = comboBox1->SelectedIndex;
Object^ selectedItem = comboBox1->SelectedItem;
MessageBox::Show( "Selected Item Text: " + selectedItem->ToString() + "\n" +
"Index: " + selectedIndex.ToString() );
}
};
}
[System::STAThreadAttribute]
int main()
{
System::Windows::Forms::Application::Run( gcnew Win32Form1Namespace::Win32Form1 );
}
using System;
using System.Windows.Forms;
namespace Win32Form1Namespace {
public class Win32Form1 : System.Windows.Forms.Form {
private System.Windows.Forms.Button addButton;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.Button addGrandButton;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.Button showSelectedButton;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button findButton;
private System.Windows.Forms.Label label1;
public Win32Form1() {
this.InitializeComponent();
}
[System.STAThreadAttribute()]
public static void Main() {
System.Windows.Forms.Application.Run(new Win32Form1());
}
private void InitializeComponent() {
this.addButton = new System.Windows.Forms.Button();
this.textBox2 = new System.Windows.Forms.TextBox();
this.addGrandButton = new System.Windows.Forms.Button();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.showSelectedButton = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.findButton = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.addButton.Location = new System.Drawing.Point(248, 32);
this.addButton.Size = new System.Drawing.Size(40, 24);
this.addButton.TabIndex = 1;
this.addButton.Text = "Add";
this.addButton.Click += new System.EventHandler(this.addButton_Click);
this.textBox2.Location = new System.Drawing.Point(8, 64);
this.textBox2.Size = new System.Drawing.Size(232, 20);
this.textBox2.TabIndex = 6;
this.textBox2.Text = "";
this.addGrandButton.Location = new System.Drawing.Point(8, 96);
this.addGrandButton.Size = new System.Drawing.Size(280, 23);
this.addGrandButton.TabIndex = 2;
this.addGrandButton.Text = "Add 1,000 Items";
this.addGrandButton.Click += new System.EventHandler(this.addGrandButton_Click);
this.comboBox1.Anchor = ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right);
this.comboBox1.DropDownWidth = 280;
this.comboBox1.Items.AddRange(new object[] {"Item 1",
"Item 2",
"Item 3",
"Item 4",
"Item 5"});
this.comboBox1.Location = new System.Drawing.Point(8, 248);
this.comboBox1.Size = new System.Drawing.Size(280, 21);
this.comboBox1.TabIndex = 7;
this.showSelectedButton.Location = new System.Drawing.Point(8, 128);
this.showSelectedButton.Size = new System.Drawing.Size(280, 24);
this.showSelectedButton.TabIndex = 4;
this.showSelectedButton.Text = "What Item is Selected?";
this.showSelectedButton.Click += new System.EventHandler(this.showSelectedButton_Click);
this.textBox1.Location = new System.Drawing.Point(8, 32);
this.textBox1.Size = new System.Drawing.Size(232, 20);
this.textBox1.TabIndex = 5;
this.textBox1.Text = "";
this.findButton.Location = new System.Drawing.Point(248, 64);
this.findButton.Size = new System.Drawing.Size(40, 24);
this.findButton.TabIndex = 3;
this.findButton.Text = "Find";
this.findButton.Click += new System.EventHandler(this.findButton_Click);
this.label1.Location = new System.Drawing.Point(8, 224);
this.label1.Size = new System.Drawing.Size(144, 23);
this.label1.TabIndex = 0;
this.label1.Text = "Test ComboBox";
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.AddRange(new System.Windows.Forms.Control[] {this.comboBox1,
this.textBox2,
this.textBox1,
this.showSelectedButton,
this.findButton,
this.addGrandButton,
this.addButton,
this.label1});
this.Text = "ComboBox Sample";
}
private void addButton_Click(object sender, System.EventArgs e) {
comboBox1.Items.Add(textBox1.Text);
}
private void addGrandButton_Click(object sender, System.EventArgs e) {
comboBox1.BeginUpdate();
for (int i = 0; i < 1000; i++) {
comboBox1.Items.Add("Item 1" + i.ToString());
}
comboBox1.EndUpdate();
}
private void findButton_Click(object sender, System.EventArgs e) {
int index = comboBox1.FindString(textBox2.Text);
comboBox1.SelectedIndex = index;
}
private void showSelectedButton_Click(object sender, System.EventArgs e) {
int selectedIndex = comboBox1.SelectedIndex;
Object selectedItem = comboBox1.SelectedItem;
MessageBox.Show("Selected Item Text: " + selectedItem.ToString() + "\n" +
"Index: " + selectedIndex.ToString());
}
}
}
Imports System.Windows.Forms
Namespace ComboBoxSampleNamespace
Public Class ComboBoxSample
Inherits System.Windows.Forms.Form
Private addButton As System.Windows.Forms.Button
Private textBox2 As System.Windows.Forms.TextBox
Private addGrandButton As System.Windows.Forms.Button
Private comboBox1 As System.Windows.Forms.ComboBox
Private showSelectedButton As System.Windows.Forms.Button
Private textBox1 As System.Windows.Forms.TextBox
Private findButton As System.Windows.Forms.Button
Private label1 As System.Windows.Forms.Label
Public Sub New()
MyBase.New()
Me.InitializeComponent()
End Sub
<System.STAThreadAttribute()> Public Shared Sub Main()
System.Windows.Forms.Application.Run(New ComboBoxSample())
End Sub
Private Sub InitializeComponent()
Me.addButton = New System.Windows.Forms.Button()
Me.textBox2 = New System.Windows.Forms.TextBox()
Me.addGrandButton = New System.Windows.Forms.Button()
Me.comboBox1 = New System.Windows.Forms.ComboBox()
Me.showSelectedButton = New System.Windows.Forms.Button()
Me.textBox1 = New System.Windows.Forms.TextBox()
Me.findButton = New System.Windows.Forms.Button()
Me.label1 = New System.Windows.Forms.Label()
Me.addButton.Location = New System.Drawing.Point(248, 32)
Me.addButton.Size = New System.Drawing.Size(40, 24)
Me.addButton.TabIndex = 1
Me.addButton.Text = "Add"
AddHandler Me.addButton.Click, AddressOf Me.addButton_Click
Me.textBox2.Location = New System.Drawing.Point(8, 64)
Me.textBox2.Size = New System.Drawing.Size(232, 20)
Me.textBox2.TabIndex = 6
Me.textBox2.Text = ""
Me.addGrandButton.Location = New System.Drawing.Point(8, 96)
Me.addGrandButton.Size = New System.Drawing.Size(280, 23)
Me.addGrandButton.TabIndex = 2
Me.addGrandButton.Text = "Add 1,000 Items"
AddHandler Me.addGrandButton.Click, AddressOf Me.addGrandButton_Click
Me.comboBox1.Anchor = ((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right)
Me.comboBox1.DropDownWidth = 280
Me.comboBox1.Items.AddRange(New Object() {"Item 1", "Item 2", "Item 3", "Item 4", "Item 5"})
Me.comboBox1.Location = New System.Drawing.Point(8, 248)
Me.comboBox1.Size = New System.Drawing.Size(280, 21)
Me.comboBox1.TabIndex = 7
Me.showSelectedButton.Location = New System.Drawing.Point(8, 128)
Me.showSelectedButton.Size = New System.Drawing.Size(280, 24)
Me.showSelectedButton.TabIndex = 4
Me.showSelectedButton.Text = "What Item is Selected?"
AddHandler Me.showSelectedButton.Click, AddressOf Me.showSelectedButton_Click
Me.textBox1.Location = New System.Drawing.Point(8, 32)
Me.textBox1.Size = New System.Drawing.Size(232, 20)
Me.textBox1.TabIndex = 5
Me.textBox1.Text = ""
Me.findButton.Location = New System.Drawing.Point(248, 64)
Me.findButton.Size = New System.Drawing.Size(40, 24)
Me.findButton.TabIndex = 3
Me.findButton.Text = "Find"
AddHandler Me.findButton.Click, AddressOf Me.findButton_Click
Me.label1.Location = New System.Drawing.Point(8, 224)
Me.label1.Size = New System.Drawing.Size(144, 23)
Me.label1.TabIndex = 0
Me.label1.Text = "Test ComboBox"
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.comboBox1, Me.textBox2, Me.textBox1, Me.showSelectedButton, Me.findButton, Me.addGrandButton, Me.addButton, Me.label1})
Me.Text = "ComboBox Sample"
End Sub
Private Sub addButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
comboBox1.Items.Add(textBox1.Text)
End Sub
Private Sub findButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim index As Integer
index = comboBox1.FindString(textBox2.Text)
comboBox1.SelectedIndex = index
End Sub
Private Sub addGrandButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
comboBox1.BeginUpdate()
Dim I As Integer
For I = 0 To 1000
comboBox1.Items.Add("Item 1" + i.ToString())
Next
comboBox1.EndUpdate()
End Sub
Private Sub showSelectedButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim selectedIndex As Integer
selectedIndex = comboBox1.SelectedIndex
Dim selectedItem As Object
selectedItem = comboBox1.SelectedItem
MessageBox.Show("Selected Item Text: " & selectedItem.ToString() & Microsoft.VisualBasic.Constants.vbCrLf & _
"Index: " & selectedIndex.ToString())
End Sub
End Class
End Namespace
注解
ComboBox 显示一个结合了 ListBox 的文本框,使用户能够从列表中选择项或输入新值。
该 DropDownStyle 属性指定列表是始终显示还是列表显示在下拉列表中。 该 DropDownStyle 属性还指定是否可以编辑文本部分。 请参阅 ComboBoxStyle 可用设置及其效果。 没有设置始终显示列表,不允许输入新值。 若要显示无法向其添加新值的列表,请使用 ListBox 控件。
若要在运行时添加或删除列表中的对象,请使用类的方法 ComboBox.ObjectCollection (通过 Items 的属性 ComboBox)。 可以使用该方法分配对象引用 AddRange 数组。 然后,该列表显示每个对象的默认字符串值。 可以使用该方法添加单个对象 Add 。 可以使用该方法删除项 Remove ,或使用该方法清除整个列表 Clear 。
除了显示和选择功能之外,还提供了 ComboBox 一项功能,使你能够有效地将项添加到 ComboBox 列表的项中并查找文本。 BeginUpdate使用和EndUpdate方法,每次将项添加到列表中时,都可以向ComboBox控件添加大量项,而无需重新绘制控件。 使用 FindString 和 FindStringExact 方法可以搜索列表中包含特定搜索字符串的项。
可以使用这些属性来管理列表中当前选定的项、 Text 用于指定在编辑字段中显示的字符串、 SelectedIndex 获取或设置当前项的属性以及 SelectedItem 获取或设置对对象的引用的属性。
注释
如果你有一ComboBox个ListBox或CheckedListBox一个基本 Windows 窗体页面,并且想要修改派生窗体中这些控件的字符串集合,则基窗体中这些控件的字符串集合必须为空。 如果字符串集合不为空,则当派生另一个窗体时,它们将变为只读。
构造函数
| 名称 | 说明 |
|---|---|
| ComboBox() |
初始化 ComboBox 类的新实例。 |
属性
| 名称 | 说明 |
|---|---|
| AccessibilityObject |
AccessibleObject获取分配给控件的控件。 (继承自 Control) |
| AccessibleDefaultActionDescription |
获取或设置控件的默认操作说明,以供辅助功能客户端应用程序使用。 (继承自 Control) |
| AccessibleDescription |
获取或设置辅助功能客户端应用程序使用的控件的说明。 (继承自 Control) |
| AccessibleName |
获取或设置辅助功能客户端应用程序使用的控件的名称。 (继承自 Control) |
| AccessibleRole |
获取或设置控件的可访问角色。 (继承自 Control) |
| AllowDrop |
获取或设置一个值,该值指示控件是否可以接受用户拖动到其中的数据。 (继承自 Control) |
| AllowSelection |
获取一个值,该值指示列表是否允许选择列表项。 (继承自 ListControl) |
| Anchor |
获取或设置控件绑定到的容器的边缘,并确定控件的父级如何调整其大小。 (继承自 Control) |
| AutoCompleteCustomSource |
获取或设置 StringCollection 在 AutoCompleteSource 属性设置为 |
| AutoCompleteMode |
获取或设置一个选项,该选项控制自动完成的工作原理 ComboBox。 |
| AutoCompleteSource |
获取或设置一个值,该值指定用于自动完成的完整字符串的源。 |
| AutoScrollOffset |
获取或设置此控件滚动到的位置 ScrollControlIntoView(Control)。 (继承自 Control) |
| AutoSize |
此属性与此类无关。 (继承自 Control) |
| BackColor |
获取或设置控件的背景色。 |
| BackgroundImage |
此属性与此类无关。 |
| BackgroundImageLayout |
获取或设置枚举中 ImageLayout 定义的背景图像布局。 |
| BindingContext |
获取或设置 BindingContext 控件。 (继承自 Control) |
| Bottom |
获取控件的下边缘与其容器工作区的上边缘之间的距离(以像素为单位)。 (继承自 Control) |
| Bounds |
获取或设置控件的大小和位置,包括其相对于父控件的非client 元素(以像素为单位)。 (继承自 Control) |
| CanEnableIme |
获取一个值,该值指示属性是否可以 ImeMode 设置为活动值,以启用 IME 支持。 (继承自 Control) |
| CanFocus |
获取一个值,该值指示控件是否可以接收焦点。 (继承自 Control) |
| CanRaiseEvents |
确定是否可以在控件上引发事件。 (继承自 Control) |
| CanSelect |
获取一个值,该值指示是否可以选择控件。 (继承自 Control) |
| Capture |
获取或设置一个值,该值指示控件是否已捕获鼠标。 (继承自 Control) |
| CausesValidation |
获取或设置一个值,该值指示控件是否导致验证在收到焦点时需要验证的任何控件上执行。 (继承自 Control) |
| ClientRectangle |
获取表示控件工作区的矩形。 (继承自 Control) |
| ClientSize |
获取或设置控件工作区的高度和宽度。 (继承自 Control) |
| CompanyName |
获取包含控件的应用程序的公司或创建者的名称。 (继承自 Control) |
| Container |
IContainer获取包含 .Component (继承自 Component) |
| ContainsFocus |
获取一个值,该值指示控件或其子控件之一当前是否具有输入焦点。 (继承自 Control) |
| ContextMenu |
已过时.
获取或设置与控件关联的快捷菜单。 (继承自 Control) |
| ContextMenuStrip |
获取或设置 ContextMenuStrip 与此控件关联的值。 (继承自 Control) |
| Controls |
获取控件中包含的控件的集合。 (继承自 Control) |
| Created |
获取一个值,该值指示是否已创建控件。 (继承自 Control) |
| CreateParams |
获取创建控件句柄时所需的创建参数。 |
| Cursor |
获取或设置鼠标指针位于控件上时显示的光标。 (继承自 Control) |
| DataBindings |
获取控件的数据绑定。 (继承自 Control) |
| DataContext |
获取或设置用于数据绑定的数据上下文。 这是一个环境属性。 (继承自 Control) |
| DataManager |
获取 CurrencyManager 与此控件关联的控件。 (继承自 ListControl) |
| DataSource |
获取或设置此 ComboBox数据源。 |
| DataSource |
获取或设置此 ListControl数据源。 (继承自 ListControl) |
| DefaultCursor |
获取或设置控件的默认游标。 (继承自 Control) |
| DefaultImeMode |
获取控件支持的默认输入法编辑器 (IME) 模式。 (继承自 Control) |
| DefaultMargin |
获取默认情况下在控件之间指定的空间(以像素为单位)。 (继承自 Control) |
| DefaultMaximumSize |
获取指定为控件的默认最大大小的长度和高度(以像素为单位)。 (继承自 Control) |
| DefaultMinimumSize |
获取指定为控件的默认最小大小的长度和高度(以像素为单位)。 (继承自 Control) |
| DefaultPadding |
获取控件内容的默认内部间距(以像素为单位)。 (继承自 Control) |
| DefaultSize |
获取控件的默认大小。 |
| DesignMode |
获取一个值,该值指示当前是否 Component 处于设计模式。 (继承自 Component) |
| DeviceDpi |
获取当前显示控件的显示设备的 DPI 值。 (继承自 Control) |
| DisplayMember |
获取或设置要为此 ListControl显示的属性。 (继承自 ListControl) |
| DisplayRectangle |
获取表示控件的显示区域的矩形。 (继承自 Control) |
| Disposing |
获取一个值,该值指示基 Control 类是否正在处理。 (继承自 Control) |
| Dock |
获取或设置哪些控件边框停靠到其父控件,并确定控件如何调整其父级的大小。 (继承自 Control) |
| DoubleBuffered |
获取或设置一个值,该值指示此控件是否应使用辅助缓冲区重新绘制其表面以减少或防止闪烁。 (继承自 Control) |
| DrawMode |
获取或设置一个值,该值指示代码还是操作系统将处理列表中元素的绘制。 |
| DropDownHeight |
获取或设置下拉部分 ComboBox的高度(以像素为单位)。 |
| DropDownStyle |
获取或设置一个值,该值指定组合框的样式。 |
| DropDownWidth |
获取或设置组合框下拉部分的宽度。 |
| DroppedDown |
获取或设置一个值,该值指示组合框是否显示其下拉部分。 |
| Enabled |
获取或设置一个值,该值指示控件是否可以响应用户交互。 (继承自 Control) |
| Events |
获取附加到此 Component对象的事件处理程序的列表。 (继承自 Component) |
| FlatStyle |
获取或设置 . ComboBox的外观。 |
| Focused |
获取一个值,该值指示是否 ComboBox 具有焦点。 |
| Font |
获取或设置控件显示的文本的字体。 (继承自 Control) |
| FontHeight |
获取或设置控件字体的高度。 (继承自 Control) |
| ForeColor |
获取或设置控件的前景色。 |
| FormatInfo |
获取或设置 IFormatProvider 提供自定义格式设置行为的设置。 (继承自 ListControl) |
| FormatString |
获取或设置指示如何显示值的格式说明符字符。 (继承自 ListControl) |
| FormattingEnabled |
获取或设置一个值,该值指示是否将格式应用于DisplayMember该属性。ListControl (继承自 ListControl) |
| Handle |
获取控件绑定到的窗口句柄。 (继承自 Control) |
| HasChildren |
获取一个值,该值指示控件是否包含一个或多个子控件。 (继承自 Control) |
| Height |
获取或设置控件的高度。 (继承自 Control) |
| ImeMode |
获取或设置控件的输入法编辑器 (IME) 模式。 (继承自 Control) |
| ImeModeBase |
获取或设置控件的 IME 模式。 (继承自 Control) |
| IntegralHeight |
获取或设置一个值,该值指示控件是否应调整大小以避免显示部分项。 |
| InvokeRequired |
获取一个值,该值指示调用方在对控件进行方法调用时是否必须调用调用方法,因为调用方与创建控件的线程不同。 (继承自 Control) |
| IsAccessible |
获取或设置一个值,该值指示控件是否对辅助功能应用程序可见。 (继承自 Control) |
| IsAncestorSiteInDesignMode |
指示此控件的上级位置之一是否位于 DesignMode 中。 此属性为只读。 (继承自 Control) |
| IsDisposed |
获取一个值,该值指示控件是否已释放。 (继承自 Control) |
| IsHandleCreated |
获取一个值,该值指示控件是否具有与之关联的句柄。 (继承自 Control) |
| IsMirrored |
获取一个值,该值指示控件是否镜像。 (继承自 Control) |
| ItemHeight |
获取或设置组合框中项的高度。 |
| Items |
获取一个对象,该对象表示此 ComboBox对象中包含的项的集合。 |
| LayoutEngine |
获取控件布局引擎的缓存实例。 (继承自 Control) |
| Left |
获取或设置控件左边缘与其容器工作区的左边缘之间的距离(以像素为单位)。 (继承自 Control) |
| Location |
获取或设置控件左上角相对于其容器左上角的坐标。 (继承自 Control) |
| Margin |
获取或设置控件之间的间距。 (继承自 Control) |
| MaxDropDownItems |
获取或设置要显示在下拉部分中 ComboBox的最大项数。 |
| MaximumSize |
获取或设置方法可以指定的上限 GetPreferredSize(Size) 的大小。 |
| MaxLength |
获取或设置用户可键入 ComboBox的字符数。 |
| MinimumSize |
获取或设置方法可以指定的下限 GetPreferredSize(Size) 的大小。 |
| Name |
获取或设置控件的名称。 (继承自 Control) |
| Padding |
此属性与此类无关。 |
| Parent |
获取或设置控件的父容器。 (继承自 Control) |
| PreferredHeight |
获取 . 的首选高度 ComboBox。 |
| PreferredSize |
获取控件可以容纳到的矩形区域的大小。 (继承自 Control) |
| ProductName |
获取包含控件的程序集的产品名称。 (继承自 Control) |
| ProductVersion |
获取包含控件的程序集的版本。 (继承自 Control) |
| RecreatingHandle |
获取一个值,该值指示控件当前是否正在重新创建其句柄。 (继承自 Control) |
| Region |
获取或设置与控件关联的窗口区域。 (继承自 Control) |
| RenderRightToLeft |
已过时.
已过时.
此属性现已过时。 (继承自 Control) |
| ResizeRedraw |
获取或设置一个值,该值指示控件在调整大小时是否重新绘制自身。 (继承自 Control) |
| Right |
获取控件右边缘与其容器工作区的左边缘之间的距离(以像素为单位)。 (继承自 Control) |
| RightToLeft |
获取或设置一个值,该值指示控件的元素是否对齐以支持使用从右到左字体的区域设置。 (继承自 Control) |
| ScaleChildren |
获取一个值,该值确定子控件的缩放。 (继承自 Control) |
| SelectedIndex |
获取或设置指定当前所选项的索引。 |
| SelectedItem |
获取或设置当前选定的项。ComboBox |
| SelectedText |
获取或设置在可编辑部分 ComboBox选择的文本。 |
| SelectedValue |
获取或设置由该属性指定的 ValueMember 成员属性的值。 (继承自 ListControl) |
| SelectionLength |
获取或设置组合框的可编辑部分选择的字符数。 |
| SelectionStart |
获取或设置组合框中所选文本的起始索引。 |
| ShowFocusCues |
获取一个值,该值指示控件是否应显示焦点矩形。 (继承自 Control) |
| ShowKeyboardCues |
获取一个值,该值指示用户界面是否处于适当的状态以显示或隐藏键盘加速器。 (继承自 Control) |
| Site |
获取或设置控件的站点。 (继承自 Control) |
| Size |
获取或设置控件的高度和宽度。 (继承自 Control) |
| Sorted |
获取或设置一个值,该值指示是否对组合框中的项进行排序。 |
| TabIndex |
获取或设置控件在其容器中的 Tab 键顺序。 (继承自 Control) |
| TabStop |
获取或设置一个值,该值指示用户是否可以使用 TAB 键向此控件提供焦点。 (继承自 Control) |
| Tag |
获取或设置包含有关控件的数据的对象。 (继承自 Control) |
| Text |
获取或设置与此控件关联的文本。 |
| Top |
获取或设置控件上边缘与其容器工作区上边缘之间的距离(以像素为单位)。 (继承自 Control) |
| TopLevelControl |
获取其他 Windows 窗体控件未父控件的父控件。 通常,这是控件包含在的最外层 Form 。 (继承自 Control) |
| UseWaitCursor |
获取或设置一个值,该值指示是否对当前控件和所有子控件使用等待游标。 (继承自 Control) |
| ValueMember |
获取或设置要用作项的实际 ListControl值的属性的路径。 (继承自 ListControl) |
| Visible |
获取或设置一个值,该值指示是否显示控件及其所有子控件。 (继承自 Control) |
| Width |
获取或设置控件的宽度。 (继承自 Control) |
| WindowTarget |
此属性与此类无关。 (继承自 Control) |
方法
活动
显式接口实现
| 名称 | 说明 |
|---|---|
| IDropTarget.OnDragDrop(DragEventArgs) |
引发 DragDrop 事件。 (继承自 Control) |
| IDropTarget.OnDragEnter(DragEventArgs) |
引发 DragEnter 事件。 (继承自 Control) |
| IDropTarget.OnDragLeave(EventArgs) |
引发 DragLeave 事件。 (继承自 Control) |
| IDropTarget.OnDragOver(DragEventArgs) |
引发 DragOver 事件。 (继承自 Control) |