ComboBoxStyle (Enumeración)
Actualización: noviembre 2007
Especifica el estilo de ComboBox.
Ensamblado: System.Windows.Forms (en System.Windows.Forms.dll)
| Nombre de miembro | Descripción | |
|---|---|---|
| Simple | La parte correspondiente al texto puede editarse. La parte correspondiente a la lista siempre se ve. | |
|
DropDown | La parte correspondiente al texto puede editarse. El usuario debe hacer clic en el botón de flecha para mostrar la parte correspondiente a la lista. Éste es el estilo predeterminado. |
|
DropDownList | El usuario no puede editar directamente la parte correspondiente al texto. El usuario debe hacer clic en el botón de flecha para mostrar la parte correspondiente a la lista. Sólo se muestra la lista si AutoCompleteMode es Suggest o SuggestAppend. |
La propiedad DropDownStyle determina si el usuario puede especificar un nuevo valor en la parte correspondiente al texto y si se muestra siempre la parte correspondiente a la lista.
Nota de la plataforma Windows Mobile para Pocket PC, Windows Mobile para Smartphone, Windows CE:
El estilo predeterminado es DropDownList.
En el ejemplo de código siguiente se muestra cómo puede inicializar un control ComboBox estableciendo la propiedad ComboBox.DropDownStyle en un valor ComboBoxStyle.
// 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.
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 Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile para Smartphone, Windows Mobile para Pocket PC
.NET Framework y .NET Compact Framework no admiten todas las versiones de cada plataforma. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.