ComboBox (cbo)
![]() | Combobox - Allows the user to either select an item from a drop-down box or enter a different item. |
Both the ComboBox and ListBox controls are derived from the ListControl class
Examples
![]() |
Useful Code
ComboBox1.Items.Add "Item 1"
ComboBox1.Items.Add "Item 2"
ComboBox1.SelectedIndex = 0
DataSource
objDataTable = New System.Data.DataTable
objDataTable.TableName = "Applications"
objDataTable.Columns.Add("ArticleApplication", GetType(System.String))
For Each objDataRow In clsDatabase.mobjDataSet.Tables("ApplicationNames").Rows
objDataRowNew = objDataTable.NewRow()
objDataRowNew("ArticleApplication") = objDataRow("ArticleApplication")
objDataTable.Rows.Add(objDataRowNew)
Next
ComboBox1.DropDownStyle = ComboBoxStyle.DropDownList
ComboBox1.DataSource = objDataTable
ComboBox1.DisplayMember = "ArticleApplication"
Properties
AllowSelection | Gets a value indicating whether the list enables selection of list items. (Inherited from ListControl.) |
AutoCompleteMode | (Added in 2.0) Gets or sets an option that controls how automatic completion works for the ComboBox. |
AutoCompleteSource | Gets or sets a value specifying the source of complete strings used for automatic completion. |
DataManager | Gets the CurrencyManager associated with this control. (Inherited from ListControl.) |
DataSource | Gets or sets the data source for this ComboBox. |
DisplayMember | Gets or sets the property to display for this ListControl. (Inherited from ListControl.) |
DropDownHeight | Gets or sets the height in pixels of the drop-down portion of the ComboBox. |
DropDownStyle | Gets or sets a value specifying the style of the combo box. |
DropDownWidth | Gets or sets the width of the of the drop-down portion of a combo box. |
DroppedDown | Gets or sets a value indicating whether the combo box is displaying its drop-down portion. |
FlatStyle | Gets or sets the appearance of the ComboBox. |
Focused | Overridden. Gets a value indicating whether the ComboBox has focus. |
FormatString | Gets or sets the format-specifier characters that indicate how a value is to be displayed. (Inherited from ListControl.) |
FormattingEnabled | Gets or sets a value indicating whether formatting is applied to the DisplayMember property of the ListControl. (Inherited from ListControl.) |
IntegralHeight | Gets or sets a value indicating whether the control should resize to avoid showing partial items. |
ItemHeight | Gets or sets the height of an item in the combo box. |
Items | Gets an object representing the collection of the items contained in this ComboBox. |
MaxDropDownItems | Gets or sets the maximum number of items to be shown in the drop-down portion of the ComboBox. |
MaxLength | Gets or sets the number of characters a user can type into the ComboBox. |
PreferredHeight | Gets the preferred height of the ComboBox. |
SelectedIndex | Problems when populating before control is displayed. Overridden. Gets or sets the index specifying the currently selected item. |
SelectedItem | Gets or sets currently selected item in the ComboBox. |
SelectedText | Gets or sets the text that is selected in the editable portion of a ComboBox. |
SelectedValue | Problems when populating before control is displayed. Gets or sets the value of the member property specified by the ValueMember property. (Inherited from ListControl.) |
SelectionLength | Gets or sets the number of characters selected in the editable portion of the combo box. |
SelectionStart | Gets or sets the starting index of text selected in the combo box. |
Sorted | Gets or sets a value indicating whether the items in the combo box are sorted. |
Text | Overridden. Gets or sets the text associated with this control. |
ValueMember | Gets or sets the property to use as the actual value for the items in the ListControl. (Inherited from ListControl.) |
Methods
Add | Adds an item to the list of items |
AddRange | Adds an array of items to the list of items |
AddItemsCore | Adds the specified items to the combo box. |
BeginUpdate | Maintains performance when items are added to the ComboBox one at a time. |
Dispose | Overloaded. Releases the resources used by the ComboBox. |
EndUpdate | Resumes painting the ComboBox control after painting is suspended by the BeginUpdate method. |
FilterItemOnProperty | Overloaded. Returns the current value of the ListControl item, if the item is a property of an instance of the ListControl class. (Inherited from ListControl.) |
FindString | Overloaded. Finds the first item in the ComboBox that starts with the specified string. |
FindStringExact | Overloaded. Finds the item that exactly matches the specified string. |
GetItemHeight | Returns the height of an item in the ComboBox. |
GetItemText | Returns the text representation of the specified item. (Inherited from ListControl.) |
OnClick | Raises the Click event. (Inherited from Control.) |
RefreshItem | Overridden. Refreshes the item contained at the specified location. |
RefreshItems | Overridden. Refreshes all ComboBox items. |
ResetText | Overridden. |
Select | Overloaded. |
SelectAll | Selects all the text in the editable portion of the ComboBox. |
SetBoundsCore | Overridden. Sets the size and location of the ComboBox. |
ToString | Overridden. Returns a string that represents the ComboBox control. |
Events
BackgroundImageChanged | Occurs when the value of the BackgroundImage property changes. |
BackgroundImageLayoutChanged | Occurs when the BackgroundImageLayout property changes. |
DrawItem | Occurs when a visual aspect of an owner-drawn ComboBox changes. |
DropDown | Occurs when the drop-down portion of a ComboBox is shown. |
DropDownClosed | Occurs when the drop-down portion of the ComboBox is no longer visible. |
DropDownStyleChanged | Occurs when the DropDownStyle property has changed. |
Format | Occurs when the control is bound to a data value. (Inherited from ListControl.) |
FormatInfoChanged | Occurs when the value of the FormatInfo property changes. (Inherited from ListControl.) |
FormatStringChanged | Occurs when value of the FormatString property changes (Inherited from ListControl.) |
FormattingEnabledChanged | Occurs when the value of the FormattingEnabled property changes. (Inherited from ListControl.) |
MeasureItem | Occurs each time an owner-drawn ComboBox item needs to be drawn and when the sizes of the list items are determined. |
SelectedIndexChanged | Occurs when the SelectedIndex property has changed. |
SelectedValueChanged | Occurs when the SelectedValue property changes. (Inherited from ListControl.) |
SelectionChangeCommitted | Occurs when the selected item has changed and that change is displayed in the ComboBox. |
TextUpdate | Occurs when the control has formatted the text, but before the text is displayed. |
ValueMemberChanged | Occurs when the ValueMember property changes. (Inherited from ListControl.) |
© 2022 Better Solutions Limited. All Rights Reserved. © 2022 Better Solutions Limited TopPrevNext