WinForms

Code Examples Upgrade Guide User Guide Demos Support Forums Download
  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class ComboBoxBase

    Show / Hide Table of Contents

    Class ComboBoxBase

    An advanced combo box control.

    Inheritance
    System.Object
    ComboDropDown
    ComboBoxBase
    ColorComboBox
    RTLComboBoxBase
    ComboBoxBaseDataBound
    ComboBoxExt
    Implements
    IThemedControl
    System.ComponentModel.ISupportInitialize
    INonClientPaintingSupport
    ISupportOffice2007Theme
    IVisualStyle
    Inherited Members
    ComboDropDown.m_lastFoundIndex
    ComboDropDown.initializing
    ComboDropDown.cachedBackColor
    ComboDropDown.cachedForeColor
    ComboDropDown.m_scrollersFrame
    ComboDropDown.autoCompleteSuccess
    ComboDropDown.OnSystemColorsChanged(EventArgs)
    ComboDropDown.OnBeginInit()
    ComboDropDown.InitPopupContainer()
    ComboDropDown.CreateTextBox()
    ComboDropDown.CreateDropDownButton()
    ComboDropDown.InitDropDownButton(DropDownButton)
    ComboDropDown.InitTextBox()
    ComboDropDown.UnInitTextBox()
    ComboDropDown.UpdatePopupControlRelationship()
    ComboDropDown.UpdatePopupBounds()
    ComboDropDown.ResetBackColor()
    ComboDropDown.ShouldSerializeBackColor()
    ComboDropDown.OnEnabledChanged(EventArgs)
    ComboDropDown.ResetDropDownWidth()
    ComboDropDown.ShouldSerializeDropDownWidth()
    ComboDropDown.ResetFlatBorderColor()
    ComboDropDown.ShouldSerializeFlatBorderColor()
    ComboDropDown.OnEnter(EventArgs)
    ComboDropDown.OnGotFocus(EventArgs)
    ComboDropDown.OnLostFocus(EventArgs)
    ComboDropDown.OnTabStopChanged(EventArgs)
    ComboDropDown.OnValidated(EventArgs)
    ComboDropDown.SetText(String, Boolean)
    ComboDropDown.GetPopupText()
    ComboDropDown.UpdateText(Boolean)
    ComboDropDown.OtherChangesMade()
    ComboDropDown.OnHandleDestroyed(EventArgs)
    ComboDropDown.OnBorderSidesChanged(EventArgs)
    ComboDropDown.OnBorder3DStyleChanged(EventArgs)
    ComboDropDown.CommitChanges()
    ComboDropDown.ResetToLatestCommittedText()
    ComboDropDown.OnDropDown(EventArgs)
    ComboDropDown.OnSelectionChangeCommitted(EventArgs)
    ComboDropDown.RaiseSelectionChangeCommitted()
    ComboDropDown.OnDropDownStyleChanged(EventArgs)
    ComboDropDown.OnReadOnlyChanged(EventArgs)
    ComboDropDown.INonClientPaintingSupport.NonClientPaint(PaintEventArgs, Rectangle, Rectangle)
    ComboDropDown.OnNewListItemKeyedIn(Int32)
    ComboDropDown.SetSelectedText(String, Int32)
    ComboDropDown.OnTextBoxKeyUp(KeyEventArgs)
    ComboDropDown.OnKeyPress(KeyPressEventArgs)
    ComboDropDown.OnKeyDown(KeyEventArgs)
    ComboDropDown.PerformAllowNewText(Message)
    ComboDropDown.IsInputKey(Keys)
    ComboDropDown.IsInputChar(Char)
    ComboDropDown.ProcessDialogKey(Keys)
    ComboDropDown.ProcessCmdKey(Message, Keys)
    ComboDropDown.ForwardKeyMessageToPopupControl(Int32, IntPtr, IntPtr)
    ComboDropDown.OnSelectionChangedOnPopupClose()
    ComboDropDown.OnPopupClosed(PopupClosedEventArgs)
    ComboDropDown.UpdatePopupControl()
    ComboDropDown.ProcessDDMouseDown(MouseEventArgs)
    ComboDropDown.ProcessDDMouseDown()
    ComboDropDown.ShowPopup()
    ComboDropDown.HidePopup()
    ComboDropDown.SetBoundsCore(Int32, Int32, Int32, Int32, BoundsSpecified)
    ComboDropDown.OnLayout(LayoutEventArgs)
    ComboDropDown.UpdateLayout(Graphics)
    ComboDropDown.SetNeedLayout(Boolean)
    ComboDropDown.DetermineHeightsBasedOnFont(Graphics, Int32)
    ComboDropDown.UpdateEditPortionBounds(Int32)
    ComboDropDown.SetTextBoxBounds(Rectangle)
    ComboDropDown.GetComboBoxDropDownWidth()
    ComboDropDown.GetOfficeStyleComboBoxDropDownWidth()
    ComboDropDown.UpdateDropDownButtonBounds()
    ComboDropDown.UpdatePopupControlBounds()
    ComboDropDown.GetEmbeddedChildBounds(Int32)
    ComboDropDown.GetEmbeddedChildBounds()
    ComboDropDown.OnPaint(PaintEventArgs)
    ComboDropDown.DrawEditPortion(PaintEventArgs)
    ComboDropDown.DrawListModeEditPortion(PaintEventArgs, Color, Color, Boolean)
    ComboDropDown.DrawDropDownPortion(PaintEventArgs)
    ComboDropDown.DrawEditPortionBorderAndBackground(PaintEventArgs)
    ComboDropDown.DrawBorderAndBackground(Graphics, Rectangle)
    ComboDropDown.DrawUnThemedBorder(Graphics, Rectangle)
    ComboDropDown.DrawUnThemedBackground(Graphics, Rectangle)
    ComboDropDown.DrawListPortion(PaintEventArgs)
    ComboDropDown.CreateScrollersFrame()
    ComboDropDown.AttachScrollersFrame(Control)
    ComboDropDown.DetachScrollersFrame()
    ComboDropDown.InitScrollersFrame()
    ComboDropDown.OnMouseMove(MouseEventArgs)
    ComboDropDown.ProcessMouseMove(MouseEventArgs, Boolean)
    ComboDropDown.OnMouseLeave(EventArgs)
    ComboDropDown.OnMouseEnter(EventArgs)
    ComboDropDown.OnMouseDown(MouseEventArgs)
    ComboDropDown.DefWndProc(Message)
    ComboDropDown.OnMouseUp(MouseEventArgs)
    ComboDropDown.OnMouseWheel(MouseEventArgs)
    ComboDropDown.OnThemeChanged(EventArgs)
    ComboDropDown.ApplyScaleToControl(Single)
    ComboDropDown.OnFontChanged(EventArgs)
    ComboDropDown.OnSizeChanged(EventArgs)
    ComboDropDown.ISupportOffice2007Theme.EnableOffice2007Style()
    ComboDropDown.IsInitializing
    ComboDropDown.SuppressDropDownEvent
    ComboDropDown.UseOffice2007ColorsInActiveMode
    ComboDropDown.UseMetroColorsInActiveMode
    ComboDropDown.Font
    ComboDropDown.UseMnemonic
    ComboDropDown.CaseSensitiveAutocomplete
    ComboDropDown.Focused
    ComboDropDown.RightToLeft
    ComboDropDown.IgnorePopupValueChange
    ComboDropDown.MatchFirstCharacterOnly
    ComboDropDown.BackColor
    ComboDropDown.NumberOnly
    ComboDropDown.ReadOnly
    ComboDropDown.CharacterCasing
    ComboDropDown.IgnoreThemeBackground
    ComboDropDown.TextAlign
    ComboDropDown.ContextMenu
    ComboDropDown.ForeColor
    ComboDropDown.Border3DStyle
    ComboDropDown.BorderSides
    ComboDropDown.LastCommittedText
    ComboDropDown.FlatStyle
    ComboDropDown.Style
    ComboDropDown.DroppedDown
    ComboDropDown.PopupContainer
    ComboDropDown.DefaultSize
    ComboDropDown.TextBox
    ComboDropDown.DropDownButton
    ComboDropDown.DropDownButtonHeight
    ComboDropDown.EditPortionHeight
    ComboDropDown.PreventHeightChange
    ComboDropDown.Text
    ComboDropDown.MaxLength
    ComboDropDown.DropDownWidth
    ComboDropDown.DropDownStyle
    ComboDropDown.FlatBorderColor
    ComboDropDown.BackgroundImage
    ComboDropDown.BackgroundImageLayout
    ComboDropDown.AllowQuickSelection
    ComboDropDown.GrayOnReadOnly
    ComboDropDown.UseBackColor
    ComboDropDown.IVisualStyle.VisualTheme
    ComboDropDown.Office2007ColorTheme
    ComboDropDown.Office2010ColorTheme
    ComboDropDown.UseMetroButtonColor
    ComboDropDown.MetroColor
    ComboDropDown.ComboBoxRenderer
    ComboDropDown.AllowMouseWheelSelection
    ComboDropDown.CreateParams
    ComboDropDown.IsPopUpControlType
    ComboDropDown.NeedLayout
    ComboDropDown.MetroBorderColor
    ComboDropDown.IThemedControl.ThemesEnabled
    ComboDropDown.BeforeTouchSize
    ComboDropDown.EnableTouchMode
    ComboDropDown.BorderSidesChanged
    ComboDropDown.Border3DStyleChanged
    ComboDropDown.DropDown
    ComboDropDown.SelectionChangeCommitted
    ComboDropDown.DropDownStyleChanged
    ComboDropDown.ReadOnlyChanged
    ComboDropDown.ThemeChanged
    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 Description
    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 Description
    System.Windows.Forms.Control
    Overrides
    ComboDropDown.PopupControl

    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 Description
    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
    ComboDropDown.AttachPopupControl()
    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 Description
    System.Drawing.Point

    CreateAccessibilityInstance()

    Declaration
    protected override AccessibleObject CreateAccessibilityInstance()
    Returns
    Type Description
    System.Windows.Forms.AccessibleObject
    Overrides
    ComboDropDown.CreateAccessibilityInstance()

    CreatePopupContainer()

    Declaration
    protected override PopupControlContainer CreatePopupContainer()
    Returns
    Type Description
    PopupControlContainer
    Overrides
    ComboDropDown.CreatePopupContainer()

    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
    ComboDropDown.DetachPopupControl(Boolean)

    Dispose(Boolean)

    Declaration
    protected override void Dispose(bool disposing)
    Parameters
    Type Name Description
    System.Boolean disposing
    Overrides
    ComboDropDown.Dispose(Boolean)

    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
    ComboDropDown.FindItem(String, Boolean, Int32, Boolean)

    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 Description
    System.String
    Overrides
    ComboDropDown.GetPopupControlItemText(Int32)

    GetPopupControlListControl()

    Declaration
    protected virtual ListControl GetPopupControlListControl()
    Returns
    Type Description
    System.Windows.Forms.ListControl

    HasListInterface()

    Declaration
    protected override bool HasListInterface()
    Returns
    Type Description
    System.Boolean
    Overrides
    ComboDropDown.HasListInterface()

    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
    ComboDropDown.IsTextValid(String)

    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
    ComboDropDown.IsValidIndex(Int32)

    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
    ComboDropDown.MoveSelelctionInPopupControl(Boolean)

    OnAutoCompleteChanged()

    Declaration
    protected virtual void OnAutoCompleteChanged()

    OnBeforePopup()

    Called before the popup gets dropped down.

    Declaration
    protected override void OnBeforePopup()
    Overrides
    ComboDropDown.OnBeforePopup()

    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
    ComboDropDown.OnEndInit()

    OnHandleCreated(EventArgs)

    Declaration
    protected override void OnHandleCreated(EventArgs e)
    Parameters
    Type Name Description
    System.EventArgs e
    Overrides
    ComboDropDown.OnHandleCreated(EventArgs)

    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
    ComboDropDown.OnMouseUpOnQuickSelect()

    OnNoChangeDetectedOnPopupClosed()

    Declaration
    protected override void OnNoChangeDetectedOnPopupClosed()
    Overrides
    ComboDropDown.OnNoChangeDetectedOnPopupClosed()

    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
    ComboDropDown.PerformTextAutoComplete(KeyPressEventArgs)

    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
    ComboDropDown.ProcessPopupControlMouseMove(Object, MouseEventArgs)

    SetPopupText(String)

    Sets the popup text.

    Declaration
    protected override void SetPopupText(string value)
    Parameters
    Type Name Description
    System.String value

    The value.

    Overrides
    ComboDropDown.SetPopupText(String)
    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
    ComboDropDown.WndProc(ref Message)

    Events

    AutoCompleteChanged

    Risen by OnAutoCompleteChanged() method.

    Declaration
    public event EventHandler AutoCompleteChanged
    Event Type
    Type Description
    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 Description
    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 Description
    SelectedIndexChangingHandler

    Implements

    IThemedControl
    System.ComponentModel.ISupportInitialize
    INonClientPaintingSupport
    ISupportOffice2007Theme
    IVisualStyle
    Back to top Generated by DocFX
    Copyright © 2001 - 2023 Syncfusion Inc. All Rights Reserved