Sign in Join
FPDoc Onlineexperiment

TCustomComboBox class

In unit StdCtrls

The base class for combo-box components.

Declaration

pascal
TCustomComboBox = class(TWinControl)

Inheritance

  1. TCustomComboBox
  2. TWinControl
  3. TControl
  4. TLCLComponent
  5. TComponent
  6. TPersistent
  7. TObject

Descends from it: TComboBox TCustomCheckCombo TCustomColorBox TCustomComboBoxEx TCustomDBComboBox TCustomFilterComboBox TPickListCellEditor

Description

TCustomComboBox is a TWinControl descendant which implements the base class for combo-box components in the LCL (Lazarus Component Library).

A combo-box is visually represented as an edit control and a scrollable list of items which can be selected. The list can always be visible, or opened when needed using a drop-down indicator. In addition, the items displayed on the control are drawn using using the built-in mechanisms for the widgetset class or using an owner-drawn style.

Despite similarities in appearance to TCustomEdit and TCustomList, the class inherits no properties from these classes (Delphi compatible).

Use Items to access the entries displayed in the drop-down list. Use AddItem or AddHistoryItem to add entries to the list of items. Use OnGetItems to dynamically populate the Items in the control when the drop-down list is displayed.

The selectable values in Items can be maintained at design-time by clicking on the ellipsis character (...) displayed next to Items in the Object Inspector.

The Text property reflects the text entered directly into the edit box, or selected either manually or by auto-completion from the Items in the list. At run-time, the entry selected from the list replaces the text in the edit box, and ItemIndex holds the (zero-based) index number of the selected item. If no value is selected from the drop-down list, the default text (if any) remains for any information typed directly into the control Text, and ItemIndex takes the value of -1.

Use Style to control the display style and drawing mechanism enabled for the drop-down list on the control.

Use AutoDropDown, AutoComplete, AutoCompleteText, and AutoDropDown to control the behavior of the edit box and its interaction with the drop-down list on the control.

Use ItemHeight and ItemWidth to control the appearance for the Items displayed on the drop-down list.

Do not create instances of TCustomComboBox. Use one of the descendent classes, like TComboBox or TComboBoxEx.

The Height property in TCustomComboBox / TComboBox cannot be changed for some platforms, including Windows and macOS. It is best to set AutoSize to True to ensure consistent size handling on the supported platforms.
Changing the value in BorderStyle to bsNone has no effect for the Windows widgetset. It is not possible to remove the border on the Windows platform.

See also

Properties

ItemHeightprotectedThe default height of an item in the drop-down for the control.
ItemWidthprotectedThe minimum width of the items in the drop-down list.
MaxLengthprotectedThe maximum length for text entered in the edit box for the control.
ParentColorprotectedUses the Color from the Parent control, when enabled.
SortedprotectedDetermines whether the list entries are sorted in alphanumeric order.
CharCasepublicIndicates the case conversion applied to the value entered in the edit box for the control.
DroppedDownpublicIndicates whether the drop-down list has been displayed.
AutoCompletepublicPositions the list box using partial text matching.
AutoCompleteTextpublicOptions for the behavior of the Auto-Complete feature.
AutoDropDownpublicMakes the drop-down list appear as soon as the user starts entering text.
AutoSelectpublicSelects the entire content of the edit box when the control receives the focus.
AutoSelectedpublicTrue indicates that the selection was marked automatically by the control.
AutoSizepublicAllows automatic adjustment of the size for the control, according to its content.
ArrowKeysTraverseListpublicIndicates if keyboard Arrow (or cursor) keys can be used to move through the list.
CanvaspublicProvides access to the drawing surface for the control.
DropDownCountpublicThe maximum number of Items visible in the drop-down list for the control.
EmulatedTextHintStatuspublicStatus for the emulated TextHint in the control.
ItemspublicThe list of items displayed in the combo-box control.
ItemIndexpublicThe index of the currently selected item, or -1 if no item is selected.
ReadOnlypublicDisallows free-form entry of Text into the combo-box edit field.
SelLengthpublicThe number of selected UTF-8 characters in the edit box.
SelStartpubliczero-based index to the UTF-8 character at the beginning of the selected text in the edit box.
SelTextpublicThe selected text in the edit box for the control.
StylepublicControls the appearance and behavior for the combo-box.
TabStoppublicEnables or disables keyboard navigation using the Tab or Shift+Tab keys.
TextpublicThe value in the edit box for the control.
TextHintpublicDefault hint text shown when the Text property is empty for the control.

Methods

WSRegisterClassprotectedRegisters this component class with the current WidgetSet.
CanShowEmulatedTextHintprotectedIndicates whether an emulated TextHint can be displayed for the control.
CreateParamsprotectedUpdates the specified creation parameters to include additional flags for the control.
InitializeWndprotectedSynchronizes the control and its widgetset class instance when the handle is created.
DestroyWndprotectedDestroys the handle for the control (and its children).
DoAutoCompleteSelectprotectedSelects an item in the control when auto-complete is enabled and activated by a key event.
DoEnterprotectedUpdates the control when the Enter key is applied.
DoExitprotectedUpdates the control when the CM_EXIT control message is handled.
DrawItemprotectedDraws a list item, using the OnDrawItem handler (when assigned).
KeyUpAfterInterfaceprotectedHandles key up events forwarded from the LCL interface.
MeasureItemprotectedGets the height for an item in the drop-down list.
GetControlClassDefaultSizeprotectedReturns the default dimensions for new instances of the class.
LMChangedprotectedHandles the LM_CHANGED message for the control.
CMWantSpecialKeyprotectedHandles the CM_WANTSPECIALKEY control message for the control.
ChangeprotectedSignals the OnChange event handler when the value for the control is changed.
SelectprotectedSignals the OnSelect event handler when ItemIndex is changed.
DropDownprotectedSignals the OnDropDown event handler.
GetItemsprotectedSignals the OnGetItems event handler.
SetItemsprotectedSets the value for the Items property.
CloseUpprotectedCalled when the drop-down list is closed.
AdjustDropDownprotectedAdjusts the extent for the drop-down list.
DoAutoAdjustLayoutprotectedPerforms actions needed to auto-adjust the control using the specified layout policy.
GetItemCountprotectedReturns the number of items defined in the drop-down list.
GetItemHeightprotectedGets the value for the ItemHeight property.
GetSelLengthprotectedGets the value for the SelLength property.
GetSelStartprotectedGets the value for the SelStart property.
GetSelTextprotectedGets the value for the SelText property.
GetItemIndexprotectedGets the value for the ItemIndex property.
GetMaxLengthprotectedGets the value for the MaxLength property.
SetDropDownCountprotectedSets the value for the DropDownCount property.
SetDroppedDownprotectedSets the value for the DroppedDown property.
SetItemHeightprotectedSets the value for the ItemHeight property.
SetItemIndexprotectedSets the value for the ItemIndex property.
SetMaxLengthprotectedSets the value for the MaxLength property.
SetSelLengthprotectedSets the value for the SelLength property.
SetSelStartprotectedSets the value for the SelStart property.
SetSelTextprotectedSets the value for the SelText property.
SetSortedprotectedSets the value for the Sorted property.
SetStyleprotectedSets the value for the Style property.
RealGetTextprotectedGets the text/caption for the control.
RealSetTextprotectedUpdates ItemIndex when the new value for the control is updated.
KeyDownprotectedFilters keys used to traverse the list.
KeyUpprotectedHandles AutoComplete and AutoSelect for the control.
UTF8KeyPressprotectedUTF8KeyPress converts character case if required then calls the inherited method.
MouseUpprotectedHighlights the selected text in the control when the left mouse button is released.
SelectItemprotectedSelects the list item with the specified text.
ShouldAutoAdjustprotectedIndicates if the width and/or height for the control can be adjusted by a layout policy.
CreatepublicConstructor for the class instance.
DestroypublicDestructor for the class instance.
IntfGetItemspublicGets the values in the Items property for the widgetset class.
AddItempublicAdds the specified string (and optional object) to the Items displayed in the control.
MatchListItempublicGets the position for the specified value in Items using the AutoCompleteText settings for the control.
AddHistoryItempublicAdd an item as the first entry in the history list for the control.
ClearpublicRemoves all items from the list, and clears the edit box.
ClearSelectionpublicRemoves the item selection in the list box for the control.
SelectAllpublicSelects the text content in the edit box for the control.

Events

OnChangeprotectedEvent handler signalled for user changes to the text in the edit box.
OnCloseUpprotectedHandler invoked when the drop-down list closes.
OnDrawItemprotectedHandler for special painting of an item (in owner-draw mode).
OnDropDownprotectedHandler invoked when the list has dropped down.
OnGetItemsprotectedHandler invoked when widgetset items list can be populated.
OnMeasureItemprotectedHandler invoked when the height for an item is needed.
OnSelectprotectedHandler invoked when an item is selected.

Inherited

From TWinControl (231)

AddControl AdjustClientRect AlignControls AllAutoSized AutoAdjustLayout AutoSizeDelayed AutoSizeDelayedHandle AutoSizeDelayedReport AutoSizePhases BeginUpdateBounds BorderStyle BorderWidth BoundsLockCount BroadCast Brush BrushCreated CachedClientHeight CachedClientWidth CalculatePreferredSize CanFocus CanSetFocus CanTab ChangeScale ChildClassAllowed ChildHandlesCreated ChildKey ChildSizing ClientRectNeedsInterfaceUpdate CMBiDiModeChanged CMBorderChanged CMDoubleBufferedChanged CMEnabledChanged CMEnter CMExit CMParentDoubleBufferedChanged CMShowHintChanged CMShowingChanged CMVisibleChanged CNChar CNKeyDown CNKeyUp CNSysKeyDown CNSysKeyUp ContainsControl ControlAtPos ControlCount ControlKeyDown ControlKeyUp Controls ControlsAligned CreateBrush CreateDockManager CreateHandle CreateParented CreateParentedControl CreateSubClass CreateWnd CustomAlignInsertBefore CustomAlignPosition DefaultHandler DefWndProc DesignerDeleting DestroyHandle DialogChar DisableAlign DoAddDockClient DoAdjustClientRectChange DoAlignChildControls DoAllAutoSize DoAutoSize DoChildSizingChange DockClientCount DockClients DockDrop DockManager DockOver DockSite DoConstraintsChange DoDockClientMsg DoDockOver DoDragMsg DoFlipChildren DoFloatMsg DoGetDockCaption DoKeyDownBeforeInterface DoKeyPress DoKeyUpBeforeInterface DoRemainingKeyDown DoRemainingKeyUp DoRemoveDockClient DoSendBoundsToInterface DoSendShowHideToInterface DoSetBounds DoubleBuffered DoUnDock DoUndockClientMsg DoUTF8KeyPress EnableAlign EndUpdateBounds EraseBackground FinalizeWnd FindChildControl FindNextControl FixDesignFontsPPIWithChildren FixupTabList FlipChildren Focused FontChanged FormEndUpdated GetAdjustedLogicalClientRect GetBorderStyle GetChildren GetChildrenRect GetClientOrigin GetClientRect GetControlIndex GetControlOrigin GetDeviceContext GetDockCaption GetEnumeratorControls GetEnumeratorControlsReverse GetMouseCapture GetParentHandle GetPreferredSizeClientFrame GetSiteInfo GetTabOrderList GetTextLen GetTopParentHandle Handle HandleAllocated HandleNeeded InsertControl IntfGetDropFilesTarget IntfUTF8KeyPress Invalidate InvalidateBoundsRealized InvalidateClientRectCache InvalidatePreferredChildSizes IsClientHeightStored IsClientWidthStored IsControlMouseMsg IsFlipped IsResizing IsSpecialSubControl KeyDownAfterInterface KeyDownBeforeInterface KeyPress KeyUpBeforeInterface Loaded LockRealizeBounds MainWndProc NotifyControls OnAlignInsertBefore OnAlignPosition OnDockDrop OnDockOver OnEnter OnExit OnGetDockCaption OnGetSiteInfo OnKeyDown OnKeyPress OnKeyUp OnUnDock OnUTF8KeyPress PaintControls PaintHandler PaintTo PaintWindow ParentDoubleBuffered ParentFormHandleInitialized ParentHandlesAllocated ParentWindow PerformTab ReAlign RealizeBounds RealizeBoundsRecursive ReloadDockedControl RemoveControl RemoveFocus Repaint ScaleBy ScaleControls ScrollBy ScrollBy_WS SelectFirst SelectNext SendDialogChar SendMoveSizeMessages SetBorderStyle SetBounds SetChildZPosition SetColor SetControlIndex SetDockManager SetFocus SetShape SetTempCursor ShowControl Showing TabOrder UnlockRealizeBounds Update UpdateControlState UpdateDockCaption UpdateShowing UseDockManager VisibleDockClientCount WindowHandle WMChar WMContextMenu WMDestroy WMEnter WMEraseBkgnd WMExit WMKeyDown WMKeyUp WMKillFocus WMMove WMNotify WMPaint WMSetFocus WMShowWindow WMSize WMSysChar WMSysKeyDown WMSysKeyUp WMWindowPosChanged WndProc WriteLayoutDebugReport WSSetText

From TControl (360)

AccessibleDescription AccessibleName AccessibleRole AccessibleValue Action ActionChange ActionLink ActiveDefaultControlChanged AddHandler AddHandlerOnBeforeDestruction AddHandlerOnChangeBounds AddHandlerOnEnabledChanged AddHandlerOnEnabledChanging AddHandlerOnKeyDown AddHandlerOnMouseWheel AddHandlerOnResize AddHandlerOnVisibleChanged AddHandlerOnVisibleChanging AdjustSize Align AnchorAsAlign AnchorClient AnchoredControlCount AnchoredControls AnchorHorizontalCenterTo AnchorParallel Anchors AnchorSame AnchorSide AnchorSideBottom AnchorSideChanged AnchorSideLeft AnchorSideRight AnchorSideTop AnchorToCompanion AnchorToNeighbour AnchorVerticalCenterTo AssignTo AutoSizing AutoSizingAll AutoSizingLockCount BaseBounds BaseParentClientSize BeforeDestruction BeforeDragStart BeginAutoDrag BeginAutoSizing BeginDrag BiDiMode BorderSpacing BoundsChanged BoundsRect BoundsRectForNewParent BringToFront CalculateDockSizes CanAutoSize Caption CaptureChanged CaptureMouseButtons ChangeBounds Changed CheckChildClassAllowed CheckNewParent CheckOnChangeBounds Click ClientHeight ClientOrigin ClientRect ClientToParent ClientToScreen ClientWidth CMChanged CMCursorChanged CMHintShow CMHitTest CMMouseEnter CMMouseLeave CMParentBiDiModeChanged CMParentColorChanged CMParentFontChanged CMParentShowHintChanged CMSysFontChanged CMTextChanged CNPreferredSizeChanged Color ColorIsStored ConstrainedResize Constraints ControlFontClass ControlOrigin ControlState ControlStyle ControlToScreen CreateAccessibleObject CreateControlBorderSpacing CreateFloatingDockSite Cursor DblClick DefineProperties DesktopFont DisableAutoSizing DoBorderSpacingChange DoCallKeyEventHandler DoCallMouseWheelEventHandler DoCallNotifyHandler Dock Docked DockOrientation DockTrackNoTarget DoContextPopup DoDock DoEndDock DoEndDrag DoFixDesignFontPPI DoMouseDown DoMouseUp DoMouseWheel DoMouseWheelDown DoMouseWheelHorz DoMouseWheelLeft DoMouseWheelRight DoMouseWheelUp DoOnChangeBounds DoOnParentHandleDestruction DoOnResize DoOnShowHint DoScaleFontPPI DoStartDock DoStartDrag DragCanceled DragCursor DragDrop Dragging DragKind DragMode DragOver EditingDone EnableAutoSizing Enabled EnabledChanged EnabledChanging EndAutoSizing EndDrag ExecuteCancelAction ExecuteDefaultAction FindSubComponent FixDesignFontsPPI Floating FloatingDockSiteClass Font ForeignAnchorSideChanged FormIsUpdating GetAccessibleObject GetAction GetActionLinkClass GetAnchorsDependingOnParent GetCachedText GetCanvasScaleFactor GetChildAccessibleObjectAtPos GetClientScrollOffset GetColorResolvingParent GetCursor GetDefaultColor GetDefaultDockCaption GetDefaultHeight GetDefaultWidth GetDockEdge GetDragImages GetEnabled GetFloating GetFloatingDockSiteClass GetLogicalClientRect GetMousePosFromMessage GetPalette GetParentBackground GetParentComponent GetPopupMenu GetPreferredSize GetRGBColorResolvingParent GetScrolledClientRect GetSelectedChildAccessibleObject GetSidePosition GetTextBuf GetTopParent HandleObjectShouldBeVisible HasHelp HasParent Height HeightIsAnchored HelpContext HelpKeyword HelpType Hide Hint HostDockSite InitiateAction InvalidateControl InvalidatePreferredSize IsAParentAligning IsBorderSpacingInnerBorderStored IsCaptionStored IsControl IsControlVisible IsEnabled IsParentColor IsParentFont IsParentOf IsProcessingPaintMsg IsRightToLeft IsVisible Left LMCaptureChanged LoadedAll LRDockWidth ManualDock ManualFloat MouseCapture MouseDown MouseEnter MouseInClient MouseLeave MouseMove Notification OnChangeBounds OnClick OnConstrainedResize OnContextPopup OnDblClick OnDragDrop OnDragOver OnEditingDone OnEndDock OnEndDrag OnMouseDown OnMouseEnter OnMouseLeave OnMouseMove OnMouseUp OnMouseWheel OnMouseWheelDown OnMouseWheelHorz OnMouseWheelLeft OnMouseWheelRight OnMouseWheelUp OnQuadClick OnResize OnShowHint OnStartDock OnStartDrag OnTripleClick Parent ParentBackground ParentBiDiMode ParentDestroyingHandle ParentFont ParentFontChanged ParentShowHint ParentToClient Perform PopupMenu PositionDockRect QuadClick ReadBounds ReadState Refresh RemoveAllHandlersOfObject RemoveHandler RemoveHandlerOnBeforeDestruction RemoveHandlerOnChangeBounds RemoveHandlerOnEnabledChanged RemoveHandlerOnEnabledChanging RemoveHandlerOnKeyDown RemoveHandlerOnMouseWheel RemoveHandlerOnResize RemoveHandlerOnVisibleChanged RemoveHandlerOnVisibleChanging ReplaceDockedControl RequestAlign Resize Scale96ToFont Scale96ToForm Scale96ToScreen ScaleConstraints ScaleDesignToForm ScaleFontsPPI ScaleFontTo96 ScaleFontToScreen ScaleFormTo96 ScaleFormToDesign ScaleScreenTo96 ScaleScreenToFont ScreenToClient ScreenToControl SendToBack SessionProperties SetAction SetAlign SetAnchors SetAutoSize SetBiDiMode SetBoundsKeepBase SetCursor SetDragMode SetEnabled SetHint SetInitialBounds SetName SetParent SetParentBackground SetParentBiDiMode SetParentComponent SetTextBuf SetVisible SetZOrder Show ShowHelp ShowHint TBDockHeight TextChanged Top TripleClick UndockHeight UndockWidth UpdateAnchorRules UpdateBaseBounds UpdateMouseCursor UpdateRolesForForm UseRightToLeftAlignment UseRightToLeftReading UseRightToLeftScrollBar Visible VisibleChanged VisibleChanging Width WidthIsAnchored WindowProc WMCancelMode WMLButtonDBLCLK WMLButtonDown WMLButtonQuadCLK WMLButtonTripleCLK WMLButtonUp WMMButtonDBLCLK WMMButtonDown WMMButtonQuadCLK WMMButtonTripleCLK WMMButtonUp WMMouseHWheel WMMouseMove WMMouseWheel WMRButtonDBLCLK WMRButtonDown WMRButtonQuadCLK WMRButtonTripleCLK WMRButtonUp WMXButtonDBLCLK WMXButtonDown WMXButtonQuadCLK WMXButtonTripleCLK WMXButtonUp

From TLCLComponent (6)

DecLCLRefCount GetWSComponentClass IncLCLRefCount LCLRefCount NewInstance WidgetSetClass

From TComponent (64)

_AddRef _Release CanObserve ChangeName ComObject ComponentCount ComponentIndex Components ComponentState ComponentStyle DesignInfo DestroyComponents Destroying ExecuteAction FindComponent FreeNotification FreeOnRelease GetChildOwner GetChildParent GetDeltaStreams GetEnumerator GetIDsOfNames GetNamePath GetObservers GetOwner GetTypeInfo GetTypeInfoCount iicrGetComponent InsertComponent Invoke IsImplementorOf Loading Name ObserverAdded Observers OnGetDeltaStreams Owner PaletteCreated QueryInterface ReadDeltaState ReadDeltaStream ReferenceInterface RemoveComponent RemoveFreeNotification RemoveFreeNotifications SafeCallException SetAncestor SetChildOrder SetDesigning SetDesignInstance SetInline SetSubComponent Tag ToString TToStringNameMode UpdateAction Updated UpdateRegistry Updating ValidateContainer ValidateInsert ValidateRename VCLComObject WriteState

From TPersistent (4)

Assign FPOAttachObserver FPODetachObserver FPONotifyObservers

From TObject (35)

AfterConstruction CheckDisposed ClassInfo ClassName ClassNameIs ClassParent ClassType CleanupInstance DefaultHandlerStr Dispatch DispatchStr Disposed DisposeOf Equals FieldAddress Free FreeInstance GetDisposed GetHashCode GetInterface GetInterfaceByStr GetInterfaceEntry GetInterfaceEntryByStr GetInterfaceTable GetInterfaceWeak GetLastCastErrorInfo InheritsFrom InitInstance InstanceSize MethodAddress MethodName QualifiedClassName StringMessageTable SystemHasExtendedRTTI UnitName

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.