All docs
V18.2
20.2 (EAP/Beta)
The page you are viewing does not exist in version 20.2. This link will take you to the root page.
20.1
The page you are viewing does not exist in version 20.1. This link will take you to the root page.
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
18.1
17.2

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