ComboBox
From Visual WebGui Wiki
| This article will have a few sections added to it soon, based on the following article type skeleton: NewControlTemplate |
Contents |
Overview
The ComboBox control is functionally equivialent to the Windows Forms ComboBox control and it displays a text box combined with a listbox, which enables the user to select items from the list or enter a new value.
The list of available items to select from can be built manually through the Items collection, or by using the DataSource property and assigning a DataSource of some kind.
Availability
The ComboBox is one of the Out of the Box standard controls, which means it is free and available in all Visual WebGui versions.
Relevant members
Properties
| Name | Description |
|---|---|
| Items | A collection of items to select from . When populating the control manually, you will use this collection to add your items. |
| DataSource | Any list that implements IList or IListSource interfaces. ArrayList being one of the typical lists that can be assigned here. |
| DisplayMember | When using DataSource, then property (field) within the DataSource that should display in the list of available values. |
| ValueMember | When using DataSource, then property (field) within the DataSource that represents the value of the currently selected item. |
| SelectedIndex | The sequential index of the currently selected item within it's source list (manual or DataSource) |
| SeletedItem |
The currently selected item. The type of this property varies, depending on the type of datasource in use. No DataSource ► nothing (use SelectedValue) DataSource is DataTable ►System.Data.DataRowView DataSource is BindingSource ►System.Data.DataRowView DataSource is any other IList or IListSource ►An item from that datasource |
| SelectedValue | The value of the currently selected item. If using the ComboBox without DataSource, then simply the item from the manually populated list. If using DataSource, then the property from the DataSource set in the ValueMember property above (defaults to ToString() if not set). |
Samples of use
- Populating with List of KeyValuePair objects
- Populating with Employees from Northwind SQL sample database
- Populating two ComboBoxes where contents of second depend on first
- Populating multiple ComboBoxes that all use the same DataSource
- Skinable (custom) combobox automatically dropping down on focus
Limitations and workarounds
Rererences
Articles
Code samples
- Create a custom multicolumn ComboBox
- Using OnPropertyChange databindings
- Control of a ComboBox with a CheckedList and a Tree
- ComboBox AutoComplete sample
Forum discussons
- Ideas for ComboBox allowing only digits
- Assigning ContextMenu in constructor may "disturb" serialization
Other references
- MSDN Windows Forms ComboBox documenation
- Bound to BindingSource ComboBox does not update it's bound source til you call EndEdit
