AdvancedComboBox Class

Represents a combo box with additional features such as customizable disabled colors, read-only mode, and more.

See the online help for an animated image example.

Definition

Namespace: KGySoft.WinForms.Controls
Assembly: KGySoft.WinForms (in KGySoft.WinForms.dll) Version: 5.0.1
C#
[ToolboxBitmapAttribute(typeof(ComboBox))]
public class AdvancedComboBox : ComboBox, 
	IReadOnlyCapable
Inheritance
Object    MarshalByRefObject    Component    Control    ListControl    ComboBox    AdvancedComboBox
Implements
IReadOnlyCapable

Remarks

The AdvancedComboBox control offers the following features in addition to ComboBox:
  • Adjustable colors in disabled state (see DisabledBackColor and DisabledForeColor).
  • TextChangedOnLeave event: occurs when leaving the control and Text is different from the value when the control received focus.
  • Auto complete works even in Simple mode.
  • Consistent font scaling on all platforms when per-monitor DPI awareness is enabled (see AutoScaleFont). Note that it affects font scaling only, so auto-sizing behavior still depends on the current platform.

Examples

The following image illustrates a few features of the AdvancedComboBox class, like the default disabled colors difference (the disabled colors are customizable), and the ReadOnly mode, which is not supported by a regular ComboBox:

AdvancedComboBox in the KGySoft.WinForms.Example application

  Tip

The image above is from the example application. At the Releases page of the project repository you can download it as executable binaries as well.

Constructors

AdvancedComboBox Creates a new instance of AdvancedComboBox

Properties

AutoCompleteMode Gets or sets how automatic completion works for the inner combo box.
Default value: None.
AutoCompleteSource Gets or sets the source of complete strings used for automatic completion.
Default value: None.
AutoScaleFont Gets or sets whether the Font should be automatically scaled when DPI changes and the current thread has per-monitor DPI awareness.
Default value: .
BackColor Gets or sets the background color of the control in the current Enabled and ReadOnly state.
(Overrides ComboBoxBackColor)
DisabledBackColor Gets or sets the background color when the control is not Enabled or is ReadOnly.
DisabledForeColor Gets or sets the text color when the control is not Enabled.
EnabledBackColor Gets or sets the background color when the control is Enabled and not ReadOnly.
EnabledForeColor Gets or sets the text color when the control is Enabled.
FontGets or sets the font of the text displayed by the control.
(Overrides ControlFont)
ForeColor Gets or sets the foreground color of the control in the current Enabled state.
(Overrides ComboBoxForeColor)
ReadOnly Gets or sets read-only state of the control.
SystemDrawDropDownListMode Gets or sets whether the combo box should have the default system appearance in DropDownList mode. If this property is , then drop-down list appearance will look similar to the DropDown mode even on Windows Vista and newer platforms.

Methods

Clear Clears the Text property. If AutoCompleteMode property is set on a simple mode combo box, then use this method to clear the text instead of setting empty string to the Text property.
DisposeReleases the unmanaged resources used by the ComboBox and optionally releases the managed resources.
(Overrides ComboBoxDispose(Boolean))
OnDrawItem Draws an item in the dropdown area and also in the control area in DropDownList mode. Works only if DrawMode is OwnerDrawFixed. It also raises the DrawItem event.
(Overrides ComboBoxOnDrawItem(DrawItemEventArgs))
OnDropDownStyleChangedRaises the DropDownStyleChanged event.
(Overrides ComboBoxOnDropDownStyleChanged(EventArgs))
OnEnabledChangedRaises the EnabledChanged event.
(Overrides ControlOnEnabledChanged(EventArgs))
OnEnterRaises the Enter event.
(Overrides ControlOnEnter(EventArgs))
OnFontChangedRaises the FontChanged event.
(Overrides ComboBoxOnFontChanged(EventArgs))
OnHandleCreatedRaises the HandleCreated event.
(Overrides ComboBoxOnHandleCreated(EventArgs))
OnHandleDestroyedRaises the HandleDestroyed event.
(Overrides ComboBoxOnHandleDestroyed(EventArgs))
OnKeyDownRaises the KeyDown event.
(Overrides ComboBoxOnKeyDown(KeyEventArgs))
OnKeyPressRaises the KeyPress event.
(Overrides ComboBoxOnKeyPress(KeyPressEventArgs))
OnLeaveRaises the Leave event.
(Overrides ControlOnLeave(EventArgs))
OnMouseDownRaises the MouseDown event.
(Overrides ComboBoxOnMouseDown(MouseEventArgs))
OnParentChangedRaises the ParentChanged event.
(Overrides ControlOnParentChanged(EventArgs))
OnParentFontChangedRaises the FontChanged event when the Font property value of the control's container changes.
(Overrides ControlOnParentFontChanged(EventArgs))
OnReadOnlyChanged Raises the ReadOnlyChanged event.
OnRightToLeftChangedRaises the RightToLeftChanged event.
(Overrides ControlOnRightToLeftChanged(EventArgs))
OnTextChangedOnLeave Raises the TextChangedOnLeave event.
WndProcProcesses Windows messages.
(Overrides ComboBoxWndProc(Message))

Events

ReadOnlyChanged Occurs when the ReadOnly property has been changed.
TextChangedOnLeave Occurs on leaving the control when Text is different from the value when the control received focus.

Extension Methods

GetFormatFlags Gets the formatting flags for the text of a custom drawn control.
(Defined by ControlExtensions)
GetScale Gets the current scale factor of the specified control. If per-monitor DPI awareness is not enabled, it always returns SystemScale.
(Defined by ScaleHelper)
GetScrollBarSize Gets the recommended width and height of scrollbars matching the current scaling of the specified control.
(Defined by ScaleHelper)
HasDefaultScaling Gets whether the display that the specified control belongs to has the same DPI as the initial DPI of the primary display.
(Defined by ScaleHelper)
ScaleHeight Scales the specified height by the vertical scale factor of the control.
(Defined by ScaleHelper)
ScaleSize Scales the specified size by the scale factor of the control.
(Defined by ScaleHelper)
ScaleWidth Scales the specified width by the horizontal scale factor of the control.
(Defined by ScaleHelper)
SetControlEnabled Sets the Enabled property of the child controls within the specified root control, or the Enabled property of the specified control itself, if it is not a recognized container control. By this way pages of a TabControl will remain selectable, a SplitContainer remains resizable, etc.
(Defined by ControlExtensions)
SetControlReadonly Recursively sets the read-only state in the children of the specified root control. Affects TextBoxBase and IReadOnlyCapable instances.
(Defined by ControlExtensions)
SetDoubleBuffered Sets the double buffered state of a control
(Defined by ControlExtensions)
SetStyle Sets a specified ControlStyles flag to either or . It calls the protected Control.SetStyle method on the specified control as if it was a public method.
(Defined by ControlExtensions)

See Also