Skip to main content
A newer version of this page is available. .

Overview - ComboBox

  • 2 minutes to read

ComboBox combines the functionality of a single-line text editor, button editor and dropdown list editor. The editor’s dropdown displays a list of items that can be selected by end-users. Selecting an item changes the editor’s edit value.

To learn more about ComboBox and see it in action, refer to our online demos.

Implementation Details

ComboBox is realized by the ComboBoxExtension class. Its instance can be accessed via the ExtensionsFactory.ComboBox helper method, which is used to add a ComboBox extension to a view. This method’s parameter provides access to the ComboBox‘s settings implemented by the ComboBoxSettings class, allowing you to fully customize the extension.

ComboBox‘s client counterpart is represented by the MVCxClientComboBox object.

Declaration

ComboBox can be added to a view in the following manner.

View code (ASPX):

<% 
    Html.DevExpress().ComboBox(
        settings => {
            settings.Name = "comboBox1";

            settings.Width = 180;
            settings.SelectedIndex = 0;
            settings.Properties.DisplayFormatString = "DXp v. {0}";
            settings.Properties.ValueType = typeof(string);

            settings.Properties.Items.Add("2009.3");
            settings.Properties.Items.Add("2010.1");
            settings.Properties.Items.Add("2010.2");
        }
    )
    .Render();
%>

View code (Razor):

@Html.DevExpress().ComboBox(
    settings => {
        settings.Name = "comboBox1";

        settings.Width = 180;
        settings.SelectedIndex = 0;
        settings.Properties.DisplayFormatString = "DXp v. {0}";
        settings.Properties.ValueType = typeof(string);

        settings.Properties.Items.Add("2009.3");
        settings.Properties.Items.Add("2010.1");
        settings.Properties.Items.Add("2010.2");
    }).GetHtml()

Note

The Partial View should contain only the extension’s code.

The code result is demonstrated in the image below.

combobox-declaration.png

See Also