ComboBox
Namespace: Wisej.Web
Assembly: Wisej.Framework (4.1.0.0)
Represents a combo box control.
- C#
- VB.NET
public class ComboBox : ListControl, ILabel, IReadOnly
Public Class ComboBox
Inherits ListControl
Implements ILabel, IReadOnly
Constructors
ComboBox()
Initializes an instance of ComboBox.
ComboBox(onSelectedIndexChanged)
Initializes a new instance of ComboBox class with specific initial settings.
| Name | Type | Description |
|---|---|---|
| onSelectedIndexChanged | Action<Object, EventArgs> | SelectedIndexChanged handler. |
ComboBox(label, onSelectedIndexChanged)
Initializes a new instance of ComboBox class with specific initial settings.
| Name | Type | Description |
|---|---|---|
| label | String | The initial text to display in the TextBox label. |
| onSelectedIndexChanged | Action<Object, EventArgs> | SelectedIndexChanged handler. |
ComboBox(dataSource, displayMember, valueMember, iconMember, onSelectedIndexChanged)
Initializes a new instance of ComboBox class with specific initial settings.
| Name | Type | Description |
|---|---|---|
| dataSource | Object | Initial DataSource. |
| displayMember | String | Initial DisplayMember. |
| valueMember | String | Initial ValueMember. |
| iconMember | String | Initial IconMember. |
| onSelectedIndexChanged | Action<Object, EventArgs> | Optional SelectedIndexChanged handler. |
ComboBox(location, size, onSelectedIndexChanged)
Initializes an instance of ComboBox with the given datasource, size, location, and action.
| Name | Type | Description |
|---|---|---|
| location | Point | Initial location. |
| size | Size | Initial size. |
| onSelectedIndexChanged | Action<Object, EventArgs> | Optional SelectedIndexChanged handler. |
ComboBox(location, size, dataSource, displayMember, valueMember, iconMember, onSelectedIndexChanged)
Initializes an instance of ComboBox with the given datasource, size, location, and action.
| Name | Type | Description |
|---|---|---|
| location | Point | Initial location. |
| size | Size | Initial size. |
| dataSource | Object | Initial DataSource. |
| displayMember | String | Initial DisplayMember. |
| valueMember | String | Initial ValueMember. |
| iconMember | String | Initial IconMember. |
| onSelectedIndexChanged | Action<Object, EventArgs> | Optional SelectedIndexChanged handler. |
ComboBox(label, location, size, onSelectedIndexChanged)
Initializes an instance of ComboBox with the given datasource, size, location, and action.
| Name | Type | Description |
|---|---|---|
| label | String | The initial text to display in the TextBox label. |
| location | Point | Initial location. |
| size | Size | Initial size. |
| onSelectedIndexChanged | Action<Object, EventArgs> | Optional SelectedIndexChanged handler. |
ComboBox(label, location, size, dataSource, displayMember, valueMember, iconMember, onSelectedIndexChanged)
Initializes an instance of ComboBox with the given datasource, size, location, and action.
| Name | Type | Description |
|---|---|---|
| label | String | The initial text to display in the TextBox label. |
| location | Point | Initial location. |
| size | Size | Initial size. |
| dataSource | Object | Initial DataSource. |
| displayMember | String | Initial DisplayMember. |
| valueMember | String | Initial ValueMember. |
| iconMember | String | Initial IconMember. |
| onSelectedIndexChanged | Action<Object, EventArgs> | Optional SelectedIndexChanged handler. |
Properties
AllowHtml
Boolean: Returns or sets a value indicating that the control can display html in the Text property. (Default: False)
AutoCompleteMode
AutoCompleteMode: Returns or sets how automatic completion works for the ComboBox. (Default: None)
Value: One of the values of AutoCompleteMode. The default is None.
AutoSize
Boolean: Returns or sets whether the height of the control is set automatically. (Default: True)
Value: true if the height of the control automatically adjusts to the font and the theme; otherwise, false. The default is true.
CharacterCasing
CharacterCasing: Returns or sets whether the ComboBox control modifies the case of characters as they are typed. (Default: Normal)
Value: One of the CharacterCasing enumeration values that specifies whether the ComboBox control modifies the case of characters. The default is CharacterCasing.Normal.
DefaultSize
Size: Returns the default size for the ComboBox control.
DropDownHeight
Int32: Returns or sets the maximum height in pixels of the drop-down portion of the ComboBox. (Default: 400)
Value: The maximum height, in pixels, of the drop-down box. The default is 400 pixels.
Throws:
- ArgumentException The specified value is less than one.
DropDownStyle
ComboBoxStyle: Returns or sets the drop down style of the combo box. (Default: DropDown)
Value: One of the ComboBoxStyle values. The default is DropDown.
DropDownWidth
Int32: Returns or sets the maximum width in pixels of the drop-down list of the ComboBox. When the value is 0, the drop-down list will grow to fit the largest item. (Default: 0)
Value: The maximum width, in pixels, of the drop-down box. The default is 0 (auto size).
Throws:
- ArgumentException The specified value is less than one.
DroppedDown
Boolean: Returns or sets whether the combo box is displaying its drop-down portion.
Value: true if the drop-down portion is displayed; otherwise, false. The default is false.
EnableNativeContextMenu
Boolean: Enables or disables the browser's context menu. (Default: True)
IncrementalSelection
Boolean: Returns or sets whether items are selected incrementally as the user types within a timeout of 1 second. (Default: True)
Value: true if items are selected incrementally; otherwise, false. The default is true.
ItemHeight
Int32: Gets or sets the height of the list items in the drop-down list. When the value is -1, uses the value set in the theme. (Default: -1)
Value: The height, in pixels, of the list items in the drop-down list. The default value is -1 (uses the value set in the theme.)
Throws:
- ArgumentOutOfRangeException The assigned value is less than -1; or the assigned value is greater than 500.
Items
ObjectCollection: Returns the collection of the items contained in this ComboBox.
Value: A ObjectCollection containing the items in the ComboBox.
Label
LabelWrapper: Provides a label related to the control.
LabelText
String: Returns or sets the localizable label associated with this control. (Default: "")
LazyLoading
Boolean: Returns or sets whether the items are sent to the client the first time the list is opened and enables the Load event. (Default: False)
MaxLength
Int32: Returns or sets the number of characters a user can type into the ComboBox. (Default: 0)
Value: The maximum number of characters a user can enter.
Throws:
- ArgumentOutOfRangeException The value is less than 0.
ReadOnly
Boolean: Returns or sets whether the control is read-only. (Default: False)
Value: true if the control is read-only; otherwise, false. The default is false.
SelectedIndex
Int32: Returns or sets the index of the currently selected item.
Value: A zero-based index of the currently selected item. -1 if no item is selected.
Throws:
- ArgumentOutOfRangeException The specified index is less than -1; o the specified index is greater than the number of items in the combo box.
SelectedItem
Object: Returns or sets currently selected item in the ComboBox.
Value: The object that is the currently selected item or null if there is no currently selected item.
SelectedText
String: Returns or sets the text that is selected in the editable portion of a ComboBox.
Value: A string that represents the currently selected text in the combo box. If DropDownStyle is set to DropDownList, the return value is an empty string ("").
SelectionLength
Int32: Returns or sets the number of characters selected in the editable portion of the combo box.
Value: The number of characters selected in the combo box.
Throws:
- ArgumentException The value was less than zero.
SelectionStart
Int32: Returns or sets the starting index of text selected in the combo box.
Value: The zero-based index of the first character in the string of the current text selection.
Throws:
- ArgumentException The value is less than zero.
Sorted
Boolean: Returns or sets whether the items in the combo box are sorted. (Default: False)
Value: true if the combo box is sorted; otherwise, false. The default is false.
Throws:
- ArgumentException An attempt was made to sort a ComboBox that is attached to a data source.
SpellCheck
Boolean: Returns or sets whether the text in the ComboBox is spell checked by the browser. (Default: False)
Value: true if the text is spell checked.
Text
String: Returns or sets the text associated with this control. (Default: "")
Value: The text associated with this control.
Tools
ComponentToolCollection: Returns the instance of ComponentToolCollection associated with this control.
Watermark
String: Returns or sets the text to show when the control is empty. (Default: null)
Methods
BeginUpdate()
Not used. Kept for compatibility.
Copy()
Copies the current selection in the text box to the Clipboard.
CreateItemCollection()
Creates a new instance of the item collection.
Returns: ObjectCollection. A ObjectCollection that represents the new item collection.
Cut()
Moves the current selection in the text box to the Clipboard.
Dispose(disposing)
Disposes the control.
| Parameter | Type | Description |
|---|---|---|
| disposing | Boolean | true when this method is called by the application rather than a finalizer. |
EndUpdate()
Not used. Kept for compatibility.
FindString(text)
Returns the index of the first item in the ComboBox that starts with the specified string.
Returns: Int32. The zero-based index of the first item found; returns -1 if no match is found.
FindString(text, startIndex)
Returns the index of the first item in the ComboBox beyond the specified index that starts with the specified string. The search is not case sensitive.
| Parameter | Type | Description |
|---|---|---|
| text | String | The String to search for. |
| startIndex | Int32 | The zero-based index of the item before the first item to be searched. Set to -1 to search from the beginning of the control. |
Returns: Int32. The zero-based index of the first item found; returns -1 if no match is found, or 0 if the text parameter specifies Empty.
FindStringExact(text)
Finds the first item in the combo box that matches the specified string.
Returns: Int32. The zero-based index of the first item found; returns -1 if no match is found, or 0 if the text parameter specifies Empty.
FindStringExact(text, startIndex)
Finds the first item after the specified index that matches the specified string.
| Parameter | Type | Description |
|---|---|---|
| text | String | The String to search for. |
| startIndex | Int32 | The zero-based index of the item before the first item to be searched. Set to -1 to search from the beginning of the control. |
Returns: Int32. The zero-based index of the first item found; returns -1 if no match is found, or 0 if the text parameter specifies Empty.
OnAutoComplete(e)
Fires the AutoComplete event.
| Parameter | Type | Description |
|---|---|---|
| e | HandledEventArgs | A HandledEventArgs that contains the event data. |
OnDataSourceChanged(e)
Fires the DataSourceChanged event.
OnDisplayMemberChanged(e)
Fires the DisplayMemberChanged event.
OnDropDown(e)
Fires the DropDown event.
OnDropDownClosed(e)
Fires the DropDownClosed event.
OnDropDownStyleChanged(e)
Fires the DropDownStyleChanged event.
OnLeave(e)
| Parameter | Type | Description |
|---|---|---|
| e | EventArgs |
OnLoad(e)
Fires the Load event.
OnReadOnlyChanged(e)
Fires the ReadOnlyChanged event.
OnSelectedIndexChanged(e)
Fires the SelectedIndexChanged event.
OnSelectedItemChanged(e)
Fires the SelectedItemChanged event.
OnSelectionChangeCommitted(e)
Fires the SelectionChangeCommitted event.
OnSortedChanged(e)
Fires the SortedChanged event.
OnToolClick(e)
Fires the ToolClick event.
| Parameter | Type | Description |
|---|---|---|
| e | ToolClickEventArgs | A ToolClickEventArgs that contains the event data. |
OnValueMemberChanged(e)
Fires the ValueMemberChanged event.
OnWebEvent(e)
Processes the event from the client.
| Parameter | Type | Description |
|---|---|---|
| e | WisejEventArgs | Event arguments. |
OnWebRender(config)
Renders the client component.
| Parameter | Type | Description |
|---|---|---|
| config | Object | Dynamic configuration object. |
OnWebUpdate(state)
Updates the client component using the state information.
| Parameter | Type | Description |
|---|---|---|
| state | Object | Dynamic state object. |
Paste()
Replaces the current selection in the text box with the contents of the Clipboard.
RefreshItem(index)
Refreshes the item contained at the specified location.
| Parameter | Type | Description |
|---|---|---|
| index | Int32 | The location of the item to refresh. |
RefreshItems()
Reloads all the ComboBox items from the data source.
Select(start, length)
Selects a range of text in the editable portion of the ComboBox.
| Parameter | Type | Description |
|---|---|---|
| start | Int32 | The position of the first character in the current text selection within the text box. |
| length | Int32 | The number of characters to select. |
SelectAll()
Selects all the text in the editable portion of the ComboBox.
SetBoundsCore(x, y, width, height, specified)
Sets the specified bounds of the ComboBox control.
| Parameter | Type | Description |
|---|---|---|
| x | Int32 | The new Left property value of the control. |
| y | Int32 | The new Top property value of the control. |
| width | Int32 | The new Width property value of the control. |
| height | Int32 | Not used. |
| specified | BoundsSpecified | A combination of the BoundsSpecified values. |
SetItemCore(index, value)
Sets the object with the specified index in the derived class.
SetItemsCore(value)
Sets the specified array of objects in a collection in the derived class.
| Parameter | Type | Description |
|---|---|---|
| value | IList | An array of items. |
Sort()
Sorts the items in the ComboBox.
Events
AutoComplete
HandledEventHandler Fired before the Validating event when DropDownStyle is set to DropDown or Simple.
The application may implement a different way to select the item when the user types a text and the ComboBox is validated. Set e.Handled to true to override the standard behavior.
this.comboBox1.AutoComplete += (s, e) =>
{
if (this.comboBox1.Text == "T")
{
this.compoBox1.SelectedIndex = 1;
e.Handled = true;
}
}
DropDown
EventHandler Fired when the drop-down portion of a ComboBox is shown.
DropDownClosed
EventHandler Fired when the drop-down portion of the ComboBox is no longer visible.
DropDownStyleChanged
EventHandler Fired when the DropDownStyle property has changed.
Load
EventHandler Fired when the drop-down list is first opened and the LazyLoading property is true.
When LazyLoading is true An application may fill the items at any time prior to the drop-down list being opened, or while processing the DropDown or Load event.
ReadOnlyChanged
EventHandler Fired when the value of the ReadOnly property has changed.
SelectedIndexChanged
EventHandler Fired when the SelectedIndex property has changed.
SelectedItemChanged
EventHandler Fired when the SelectedItem property has changed.
SelectionChangeCommitted
EventHandler Fired when the selected item has changed and that change is displayed in the ComboBox.
SortedChanged
EventHandler Fired when the Sorted property has changed.
ToolClick
ToolClickEventHandler Fired when a ComponentTool is clicked.
Inherited By
| Name | Description |
|---|---|
| DataGridViewComboBoxEditingControl | Represents a ComboBox control that can be hosted in a DataGridViewComboBoxCell. |
| ListViewComboBox | The TreeViewComboBox control represents a UserComboBox control with a ListView as the drop down panel. |
| TreeViewComboBox | The TreeViewComboBox control represents a UserComboBox control with a TreeView as the drop down panel. |
| UserComboBox | The UserComboBox control represents a ComboBox control with a custom panel that drops down when the user clicks the down arrow. |
Implements
| Name | Description |
|---|---|
| IUserData | Provides access to the UserData and Tag properties associated to the component implementing this interface. |
| IBindableComponent | Bindable components implement this interface. |
| IDropTarget | Controls that support drag & drop operations implement this interface. |
| ILabel | Provides access to the LabelWrapper associated with the controls that implement this interface. |
| IReadOnly | Provides access to the ReadOnly property for coontrols that support the read-only mode. |
| IModified | Provides access to the Modified property and ModifiedChanged event for controls that implement this interface. |
| IValidation | Provides access to the validation events and properties property for controls that support validation. |
| IWisejComponent | All wisej components implement this interface. |
| IWisejControl | All wisej controls derived from the Control class must implement this interface. |
| IWisejSerializable | Allows an object to serialize itself. |