ComboBoxStyle Enumeration

Specifies the ComboBox style.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

'Declaration
Public Enumeration ComboBoxStyle
'Usage
Dim instance As ComboBoxStyle

public enum ComboBoxStyle
public enum ComboBoxStyle

 Member nameDescription
Supported by the .NET Compact FrameworkDropDownThe text portion is editable. The user must click the arrow button to display the list portion. This is the default style. 
Supported by the .NET Compact FrameworkDropDownListThe user cannot directly edit the text portion. The user must click the arrow button to display the list portion. The list displays only if AutoCompleteMode is Suggest or SuggestAppend
SimpleThe text portion is editable. The list portion is always visible. 

The DropDownStyle property determines whether the user can enter a new value in the text portion, and whether the list portion is always displayed.

Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows CE Platform Note: The default style is DropDownList.

The following code example demonstrates how to initialize a ComboBox control by setting the ComboBox.DropDownStyle property to a ComboBoxStyle value.


' 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.
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

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Community Additions

ADD
Show: