Class ComboBoxBase
An advanced combo box control.
Inheritance
Implements
Inherited Members
Namespace: Syncfusion.Windows.Forms.Tools
Assembly: Syncfusion.Shared.Base.dll
Syntax
public class ComboBoxBase : ComboDropDown, IThemedControl, ISupportInitialize, INonClientPaintingSupport, ISupportOffice2007Theme, IVisualStyle
Remarks
This advanced combo box control provides a lot of improvements over the standard System.Windows.Forms.ComboBox control. The improvements are as follows:
- Plug in any System.Windows.Forms.ListControl derived class as the list for the list portion of the combo box using the ListControl property.
- Provides a System.Windows.Forms.FlatStyle mode for regular, flat or themed drawing.
- Written using native .NET controls, this control lets you customize everything in the combo box from the textbox to the drop-down window.
This control requires the plugged in ListControl to implement the Items property returning a valid System.Collections.IList instance. The ListControl can optionally implement an IndexFromPoint method that will take a single argument of type System.Drawing.Point and a TopIndex property of type int. The semantics of these above properties and methods are similar to that of a System.Windows.Forms.ListBox's implementation.
Implementing IndexFromPoint and TopIndex will enable QuickSelection capability for the combo box, wherein the user can click on the drop-down button and start selecting items in the list, all this without releasing the mouse.
Constructors
ComboBoxBase()
Creates a new instance of the ComboBoxBase class.
Declaration
public ComboBoxBase()
Remarks
Initializing this ComboBoxBase also requires you to set the ListControl property of this combo box.
Properties
AutoComplete
Gets a value indicating whether the control uses AutoComplete.
Declaration
public bool AutoComplete { get; set; }
Property Value
| Type |
|---|
| System.Boolean |
ListControl
Gets or sets the System.Windows.Forms.ListControl that will be used in the drop-down portion.
Declaration
public virtual ListControl ListControl { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Windows.Forms.ListControl | A System.Windows.Forms.ListControl derived instance. |
Remarks
Take a look at the ComboBoxBase class description for more information on requirements and usage of this list control.
PopupControl
This will be used in the drop-down portion.
Declaration
public override Control PopupControl { get; set; }
Property Value
| Type |
|---|
| System.Windows.Forms.Control |
Overrides
UpdateSelectionBeforeValidate
Indicates whether the selection in the list control should be updated with the new text entered by the user when the control loses focus.
Declaration
public virtual bool UpdateSelectionBeforeValidate { get; set; }
Property Value
| Type |
|---|
| System.Boolean |
Remarks
This property is typically used only when the list mode is set to editable (DropDown).
Methods
AttachPopupControl()
Called when a new System.Windows.Forms.ListControl gets attached to this ComboBoxBase using the ListControl property.
Declaration
protected override void AttachPopupControl()
Overrides
Remarks
When you override this method, make sure to call the base class for proper initialization.
CorrectPopupLocation(Point)
Correct popup control location.
Declaration
protected virtual Point CorrectPopupLocation(Point location)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Drawing.Point | location |
Returns
| Type |
|---|
| System.Drawing.Point |
CreateAccessibilityInstance()
Declaration
protected override AccessibleObject CreateAccessibilityInstance()
Returns
| Type |
|---|
| System.Windows.Forms.AccessibleObject |
Overrides
CreatePopupContainer()
Declaration
protected override PopupControlContainer CreatePopupContainer()
Returns
| Type |
|---|
| PopupControlContainer |
Overrides
DetachPopupControl(Boolean)
Called when an attached System.Windows.Forms.ListControl is being detached from this combo.
Declaration
protected override void DetachPopupControl(bool disposing)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | disposing | Indicates whether this method is called from Dispose. |
Overrides
Dispose(Boolean)
Declaration
protected override void Dispose(bool disposing)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | disposing |
Overrides
FindItem(String, Boolean, Int32, Boolean)
Called to find a matching item in the attached ListControl given the prefix of the item.
Declaration
protected override int FindItem(string prefix, bool select, int start, bool ignoreCase)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | prefix | The prefix string. |
| System.Boolean | select | Indicates whether to change the selection in the list when a match occurs. |
| System.Int32 | start | The index within each list item-string, where the search begins. |
| System.Boolean | ignoreCase | Indicates whether to ignore case. |
Returns
| Type | Description |
|---|---|
| System.Int32 | The index of the matching item; -1 otherwise. |
Overrides
GetIndexFromPoint(Point)
Returns the index of the item at the specified point.
Declaration
protected virtual int GetIndexFromPoint(Point pointScreen)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Drawing.Point | pointScreen | A System.Drawing.Point in screen coordinates. |
Returns
| Type | Description |
|---|---|
| System.Int32 | The zero based index; -1 if the point is not over an item. |
GetListControlList()
Returns the System.Collections.IList interface representing the item's collection of the attached ListControl.
Declaration
protected virtual IList GetListControlList()
Returns
| Type | Description |
|---|---|
| System.Collections.IList | An IList interface. |
Remarks
The base class version looks for the "Items" property in the attached ListControl.
GetPopupControlItemText(Int32)
Returns the text representation of the specified item in PopUpControl.
Declaration
protected override string GetPopupControlItemText(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | The index. |
Returns
| Type |
|---|
| System.String |
Overrides
GetPopupControlListControl()
Declaration
protected virtual ListControl GetPopupControlListControl()
Returns
| Type |
|---|
| System.Windows.Forms.ListControl |
HasListInterface()
Declaration
protected override bool HasListInterface()
Returns
| Type |
|---|
| System.Boolean |
Overrides
IsIndexFromPointAvaillable()
Indicates whether the attached ListControl has an "IndexFromPoint" method.
Declaration
protected virtual bool IsIndexFromPointAvaillable()
Returns
| Type | Description |
|---|---|
| System.Boolean | True if such a method is available; False otherwise. |
Remarks
This control relies on the attached ListControl providing this method to support quick-selection mode. This is the mode where the user can click on the drop-down arrow and start selecting in the drop-down list even before mouse up.
IsTextValid(String)
Indicates whether the supplied text is a valid entry in the attached ListControl.
Declaration
protected override bool IsTextValid(string text)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | text | The text to validate. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if valid; False otherwise. |
Overrides
IsValidIndex(Int32)
Indicate whether ListControl contains item with such index.
Declaration
protected override bool IsValidIndex(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | The index. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True - if there is such item, otherwise - false. |
Overrides
MoveSelelctionInPopupControl(Boolean)
Moves the current selection in the attached ListControl.
Declaration
protected override void MoveSelelctionInPopupControl(bool up)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | up | Indicates whether to move up. |
Overrides
OnAutoCompleteChanged()
Declaration
protected virtual void OnAutoCompleteChanged()
OnBeforePopup()
Called before the popup gets dropped down.
Declaration
protected override void OnBeforePopup()
Overrides
OnDropDownCloseOnClick(MouseClickCancelEventArgs)
Raises the DropDownCloseOnClick event.
Declaration
protected virtual void OnDropDownCloseOnClick(MouseClickCancelEventArgs args)
Parameters
| Type | Name | Description |
|---|---|---|
| MouseClickCancelEventArgs | args | A MouseClickCancelEventArgs that contains the event data. |
Remarks
Raising an event invokes the event handler through a delegate. For more information, see Raising an Event.
The OnDropDownCloseOnClick method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
Note to Inheritors: When overriding OnDropDownCloseOnClick in a derived class, be sure to call the base class's OnDropDownCloseOnClick method so that registered delegates receive the event.
OnEndInit()
Declaration
protected override void OnEndInit()
Overrides
OnHandleCreated(EventArgs)
Declaration
protected override void OnHandleCreated(EventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.EventArgs | e |
Overrides
OnListMouseUp(MouseEventArgs)
Called when the user clicks on the associated list box.
Declaration
protected virtual void OnListMouseUp(MouseEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.Forms.MouseEventArgs | e | The MouseEventArgs from the list box's MouseUp event. |
OnListSelectedValueChangedWhileNotShowingPopup(Int32)
Declaration
protected virtual void OnListSelectedValueChangedWhileNotShowingPopup(int newIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | newIndex |
OnMouseUpOnQuickSelect()
Handles the PopupCloseType of PopUpContainer based on SelectedIndex.
Declaration
protected override void OnMouseUpOnQuickSelect()
Overrides
OnNoChangeDetectedOnPopupClosed()
Declaration
protected override void OnNoChangeDetectedOnPopupClosed()
Overrides
OnSelectedIndexChanging(SelectedIndexChangingArgs)
Fires SelectedIndexChanging event.
Declaration
protected virtual void OnSelectedIndexChanging(SelectedIndexChangingArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| SelectedIndexChangingArgs | e |
OnSelectionChangedByKey()
Declaration
protected virtual void OnSelectionChangedByKey()
OnUpdateSelectionBeforeValidate()
Called to update selection before validate.
Declaration
protected virtual void OnUpdateSelectionBeforeValidate()
Remarks
This is useful when you enable auto completion in the text area and force the list box's SelectedValue to be updated to the latest text value in this control's Validated event.
OnValidating(CancelEventArgs)
Raises the Validating event.
Declaration
protected override void OnValidating(CancelEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.ComponentModel.CancelEventArgs | e |
PerformTextAutoComplete(KeyPressEventArgs)
Declaration
protected override void PerformTextAutoComplete(KeyPressEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.Forms.KeyPressEventArgs | e |
Overrides
ProcessListMouseMove(Object, MouseEventArgs)
Processes mouse move over the list.
Declaration
protected virtual void ProcessListMouseMove(object sender, MouseEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | sender | The control source of the MouseMove event. |
| System.Windows.Forms.MouseEventArgs | e | The event args of the MouseMove event. |
Remarks
This method moves the selection of the attached ListControl in some cases when the mouse moves over it and also to change the Top Index of the list control appropriately when QuickSelection is on.
ProcessPopupControlMouseMove(Object, MouseEventArgs)
Processes the mouse move over the PopupControl.
Declaration
protected override void ProcessPopupControlMouseMove(object sender, MouseEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | sender | |
| System.Windows.Forms.MouseEventArgs | e |
Overrides
SetPopupText(String)
Sets the popup text.
Declaration
protected override void SetPopupText(string value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The value. |
Overrides
Remarks
Compares the new PopUpText and resets if a match is not found.
WndProc(ref Message)
Declaration
protected override void WndProc(ref Message m)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.Forms.Message | m |
Overrides
Events
AutoCompleteChanged
Risen by OnAutoCompleteChanged() method.
Declaration
public event EventHandler AutoCompleteChanged
Event Type
| Type |
|---|
| System.EventHandler |
DropDownCloseOnClick
Occurs when the user clicks in the list box in the drop-down to let you cancel the subsequent drop-down close.
Declaration
public event MouseClickCancelEventHandler DropDownCloseOnClick
Event Type
| Type |
|---|
| MouseClickCancelEventHandler |
SelectedIndexChanging
Occurs when the selected Index of list is about to be changed. Can be canceled to avoid selection of the specific item.
Declaration
public event SelectedIndexChangingHandler SelectedIndexChanging
Event Type
| Type |
|---|
| SelectedIndexChangingHandler |