ListBoxControl Class

The list box control that displays a list of items that a user can select. Can be populated with items from a data source.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.XtraEditors.v20.1.dll

Declaration

[ListBoxControl.ListBoxControlCustomBindingProperties]
public class ListBoxControl :
    BaseListBoxControl,
    IBehaviorPropertiesFilter
<ListBoxControl.ListBoxControlCustomBindingProperties>
Public Class ListBoxControl
    Inherits BaseListBoxControl
    Implements IBehaviorPropertiesFilter

Remarks

By default, the ListBoxControl renders its items as text strings.

ListBoxControl - class

The Item Templates feature helps you render each listbox item as your needs dictate. Each item can display multiple text and image elements arranged in any manner, and painted using different appearance settings.

ListboxControl-ItemTemplate-and-result

The control's main members include:

Search & Filtering

You can provide end-users with the ability to filter items in a ListBoxControl. For this purpose, attach the ListBoxControl to a SearchControl by using the SearchControl.Client property.


searchControl1.Client = listBoxControl1;

When an end-user types a search request into the SearchControl, the ListBoxControl automatically filters its items, and highlights the requested string in the filtered items.

ListBoxControl_SearchHighlight

NOTE

If items are formatted using the HTML tags (see BaseListBoxControl.AllowHtmlDraw), the items are filtered, but not highlighted.

Examples

The following sample code demonstrates how to initialize and create a new instance of the ListBoxControl class at runtime.

ListBoxControl-ctor

using DevExpress.XtraEditors;
// ...
// Initialize an array of strings
string[] States = {
                     "Alabama",
                     "Alaska",
                     "Arizona",
                     "California",
                     "Colorado",
                     "Florida",
                     "Idaho",
                     "Kansas",
                     "Michigan",
                     "Nevada",
                     "Texas",
                     "Utah"
                  };
// Initialize and create an instance of the ListBoxControl class
ListBoxControl listBox = new ListBoxControl();
// Define the parent control
listBox.Parent = this;
// Set the listBox's background color
listBox.BackColor = Color.FromArgb(254, 246, 212);
// Dock to all edges and fill the parent container
listBox.Dock = DockStyle.Fill;
// Add items
listBox.Items.AddRange(States);
See Also