HypernovaDesktop Components · docs
Binarymission
WinFormsCombo Box › BinaryComboBox

BinaryComboBox

class.NET 6 / 8 / 10.NET Framework 4.8Binarymission.WinForms.Controls.ListControls

BinaryComboBox - Base ComboBox class.

public abstract class BinaryComboBox : System.Windows.Forms.ComboBox

Inherits from / implements: System.Windows.Forms.ComboBox

Remarks

BinaryComboBox class represents the base abstract class for BinaryImageComboBox and BinaryTextComboBox classes.

This base class BinaryComboBox is not designed with an intention of deriving and creating classes other than the two specialist ComboBox classes BinaryTextComboBox and BinaryImageComboBox.
In order to customise the control, only derive from the specialist classes BinaryTextComboBox and BinaryImageComboBox.

Members at a glance

BinaryComboBoxInitializes a new instance of BinaryComboBox class.
AlphaBlendFactorForControlPaintingGets or sets the Alpha blending factor value for use when painting the control.
AlphaBlendFactorForDropDownPressedColorGets or sets the Alpha blending factor value for use when painting the "pressed" state of the control.
AlphaBlendFactorForItemSelectionColorGets or sets the Alpha blending factor value for use when painting the Item selection background.
ControlArrowColorGets or sets the color of the control's drop-down indicating arrow.
CustomControlBorderColorGets or sets the Color value for painting the Control's border.
CustomControlBorderColorWhenNotInFocusThe border color used while the control does not have the focus, when a custom border color is in effect.
CustomControlDropDownButtonFillColorWhenNotInFocusGets or sets the custom control drop down button fill color when not in focus.
CustomPaintingColorGets or sets the Color value for painting the Control.
DropDownItemBorderColorGets or sets the color of each of the item in the dropdown window.
DropDownItemTextAlignmentGets or sets the text align of the item in the drop-down window.
DropDownStyleSince the control does not support Simple for its DropDownStyle, a new implementation is provided for this property.
DropDownWindowBackgroundColorGets or sets the background color of the dropped-down window, when the control is not in multi-column drop style (refer DropStyleIsMultiColumn for what is multi-column drop style).
DropDownWindowBorderColorGets or sets the color of the dropdown window border.
DropDownWindowBorderThicknessGets or sets the drop-down window border thickness.
ExtendedDropdownButtonImageGets or sets the extended drop-down button image. This will draw the entire drop-down section using your image. The ideal size is 17 x 23 pixels.
ExtendedDropdownButtonInternalImageGets or sets the extended drop-down button's internal image when using the default built in extended drop-down button. The ideal size is 6 x 6 pixels.
IsInExtendedReadOnlyModeGets or sets whether the control is in extended read-only mode
MultiColumnDropDownWindowBorderThicknessGets or sets the multi-column drop-down window border thickness, in logical (96 DPI) units - scaled to the display the window opens on. Anything under 2 draws as 2.
MultiColumnWindowColumnsHorizontalAlignmentsGets or sets the multi-column window columns horizontal alignments.
ReflectCurrentXPThemeColorOnLoadGets or sets whether the control should paint itself based on the current active XP theme.
RightToLeftRightToLeft is currently not supported. Planned for future release.
ShouldApplyMultiColumnWindowColumnsAlignmentsToAutoCompleteDropDownGets or sets a value indicating whether the control should apply the multi-column window columns alignments setting (as is MultiColumnWindowColumnsHorizontalAlignments to apply to the auto-complete multi-column drop down too.
ShouldDisplayColumnHeadersWhenInMultiColumnModeGets or sets a value indicating whether the should display column headers when information multi column mode.
ShouldDrawExtendedDropdownButtonGets or sets a value indicating whether the control should draw extended drop down button for the drop down button section.
ShowBorderAlwaysGets or sets whether the control will always have its border displayed, even when the control is not currently in focus.
TextAlignmentGets or sets the text align.
UpdateWhenSystemColorsChangesGets or sets whether the control needs to repaint itself when the SystemColorsChanged event is raised.
DropDownButtonExtentThe width of the drop-down button strip at the right of the control.
EmulateThisXPThemeEnables painting the control with XP theme colors.
MakeBlankThis method helps to deterministically set the control's text area to blank.
MeasureTextViaGdiMeasures text the way GDI draws it, which is not the same as the GDI+ measurement Graphics.MeasureString gives and is what the row heights have to be based on.
OnDrawItemRefer to base class documentation.
OnGotFocusRefer to base class documentation.
OnHandleCreatedRefer to base class documentation.
OnKeyPressRefer to base class documentation.
OnLostFocusRefer to base class documentation.
OnMouseEnterRefer to base class documentation.
OnMouseLeaveRefer to base class documentation.
OnPaintRefer to base class documentation.
OnSelectedIndexChangedRefer to base class documentation.
OnSystemColorsChangedRefer to base class documentation.
PaintControlWithDataDraws the closed control for the item at the given index. Override to change how a selected item is presented on the control face.
RefreshPaintRedraws the control face after the selection changes, without a full layout pass.
SetDataRefreshes the text drawn on the closed control from the current selection. The base handles the flat display style; a derived combo box overrides it for its own item shape.
WndProcRefer to base class documentation.
DropDownButtonWidthWidth in pixels of the drop-down button at the right-hand end of the control.

Constructors

BinaryComboBox

public BinaryComboBox()

Initializes a new instance of BinaryComboBox class.

Properties

AlphaBlendFactorForControlPainting

public int AlphaBlendFactorForControlPainting

Gets or sets the Alpha blending factor value for use when painting the control.

Value. A Int32 value.

Set this property with a value of your choice, to alpha blend/smoothen the control's painting color.

AlphaBlendFactorForDropDownPressedColor

public int AlphaBlendFactorForDropDownPressedColor

Gets or sets the Alpha blending factor value for use when painting the "pressed" state of the control.

Value. A Int32 value.

Set this property with a value of your choice, to alpha blend/smoothen the control's "pressed state" painting color.

AlphaBlendFactorForItemSelectionColor

public int AlphaBlendFactorForItemSelectionColor

Gets or sets the Alpha blending factor value for use when painting the Item selection background.

Value. A Int32 value.

Set this property with a value of your choice, to alpha blend/smoothen the control's painting color used when painting the Item selection background.

ControlArrowColor

public Color ControlArrowColor

Gets or sets the color of the control's drop-down indicating arrow.

CustomControlBorderColor

public Color CustomControlBorderColor

Gets or sets the Color value for painting the Control's border.

Value. A Color value.

Set this property with a valid Color value of your choice, to paint the control's border.
By default, this property is set to Highlight value.

CustomControlBorderColorWhenNotInFocus

public Color CustomControlBorderColorWhenNotInFocus

The border color used while the control does not have the focus, when a custom border color is in effect.

CustomControlDropDownButtonFillColorWhenNotInFocus

public Color CustomControlDropDownButtonFillColorWhenNotInFocus

Gets or sets the custom control drop down button fill color when not in focus.

CustomPaintingColor

public Color CustomPaintingColor

Gets or sets the Color value for painting the Control.

Value. A Color value.

Set this property with a valid Color value of your choice, to paint the control.
By default, this property is set to Highlight value.

DropDownItemBorderColor

public Color DropDownItemBorderColor

Gets or sets the color of each of the item in the dropdown window.

This is applicable for single column mode dropdown window.

DropDownItemTextAlignment

public HorizontalAlignment DropDownItemTextAlignment

Gets or sets the text align of the item in the drop-down window.

DropDownStyle

public new ComboBoxStyle DropDownStyle

Since the control does not support Simple for its DropDownStyle, a new implementation is provided for this property.

DropDownWindowBackgroundColor

public Color DropDownWindowBackgroundColor

Gets or sets the background color of the dropped-down window, when the control is not in multi-column drop style (refer DropStyleIsMultiColumn for what is multi-column drop style).

DropDownWindowBorderColor

public Color DropDownWindowBorderColor

Gets or sets the color of the dropdown window border.

This is applicable for single column mode dropdown window.

DropDownWindowBorderThickness

public float DropDownWindowBorderThickness

Gets or sets the drop-down window border thickness.

ExtendedDropdownButtonImage

public Bitmap ExtendedDropdownButtonImage

Gets or sets the extended drop-down button image. This will draw the entire drop-down section using your image. The ideal size is 17 x 23 pixels.

ExtendedDropdownButtonInternalImage

public Bitmap ExtendedDropdownButtonInternalImage

Gets or sets the extended drop-down button's internal image when using the default built in extended drop-down button. The ideal size is 6 x 6 pixels.

IsInExtendedReadOnlyMode

public bool IsInExtendedReadOnlyMode

Gets or sets whether the control is in extended read-only mode

When in this mode, the control not only does not allow the user to type text into the text area of the control, but also does not let the user change the current item by selecting another item via keyboard up/down/page up/page down keys and the drop-down list selection.

MultiColumnDropDownWindowBorderThickness

public float MultiColumnDropDownWindowBorderThickness

Gets or sets the multi-column drop-down window border thickness, in logical (96 DPI) units - scaled to the display the window opens on. Anything under 2 draws as 2.

MultiColumnWindowColumnsHorizontalAlignments

public IList<HorizontalAlignment> MultiColumnWindowColumnsHorizontalAlignments

Gets or sets the multi-column window columns horizontal alignments.

ReflectCurrentXPThemeColorOnLoad

public bool ReflectCurrentXPThemeColorOnLoad

Gets or sets whether the control should paint itself based on the current active XP theme.

This property will have effect only when the control is running in Windows XP Operating system.
Every time the hosting container (i.e. a Form, etc.) is loaded, the control will draw itself with the relevant colors to simulate the current active XP theme.
The default value is false.

RightToLeft

public override RightToLeft RightToLeft

RightToLeft is currently not supported. Planned for future release.

ShouldApplyMultiColumnWindowColumnsAlignmentsToAutoCompleteDropDown

public bool ShouldApplyMultiColumnWindowColumnsAlignmentsToAutoCompleteDropDown

Gets or sets a value indicating whether the control should apply the multi-column window columns alignments setting (as is MultiColumnWindowColumnsHorizontalAlignments to apply to the auto-complete multi-column drop down too.

ShouldDisplayColumnHeadersWhenInMultiColumnMode

public bool ShouldDisplayColumnHeadersWhenInMultiColumnMode

Gets or sets a value indicating whether the should display column headers when information multi column mode.

ShouldDrawExtendedDropdownButton

public bool ShouldDrawExtendedDropdownButton

Gets or sets a value indicating whether the control should draw extended drop down button for the drop down button section.

ShowBorderAlways

public bool ShowBorderAlways

Gets or sets whether the control will always have its border displayed, even when the control is not currently in focus.

If set to true, the control will always display its border even when the input focus is not on the control.
By default, this property is set to false.

TextAlignment

public HorizontalAlignment TextAlignment

Gets or sets the text align.

UpdateWhenSystemColorsChanges

public bool UpdateWhenSystemColorsChanges

Gets or sets whether the control needs to repaint itself when the SystemColorsChanged event is raised.

Methods

DropDownButtonExtent

protected internal int DropDownButtonExtent()

The width of the drop-down button strip at the right of the control.

Every site that needed this width used the Windows scroll-bar metric, which is DPI aware but takes no account of the control's font. That is right for a combo box at the default face and wrong the moment a caller picks a larger one: the box grows with the text while the button stays behind, a seventeen-pixel sliver against a forty-pixel box. All of them moved here together, so the button, the text area beside it and the drop-down's own position stay in agreement. The system metric is the floor, so nothing that fits today gets smaller.

EmulateThisXPTheme

public void EmulateThisXPTheme (XPTheme theTheme)

Enables painting the control with XP theme colors.

theTheme
A supported XP theme.
Call this method whenever you need to render the control using a supported XP theme.
Note: The control Emulates painting the control with an XP theme as closely as possible.
This may not achieve an exact reproduction of XP theme color (since the simulation is custom drawn). This method can render the control with emulated XP theme colors even in Windows 2000 Operating System.
Refer to XPTheme enumeration for the supported XP themes.
Note: When this method is called, any values that has been already set for color properties CustomPaintingColor, CustomControlBorderColor and alpha-blending factor properties AlphaBlendFactorForControlPainting, AlphaBlendFactorForDropDownPressedColor and AlphaBlendFactorForItemSelectionColor will be lost.
If you need your custom values later (after calling this method), please save them temporarily in your application.

MakeBlank

public void MakeBlank()

This method helps to deterministically set the control's text area to blank.

Note that once the text area is made to display blank, the control's SelectedIndex

MeasureTextViaGdi

protected static Size MeasureTextViaGdi(Graphics graphics, string text, Font font)

Measures text the way GDI draws it, which is not the same as the GDI+ measurement Graphics.MeasureString gives and is what the row heights have to be based on.

graphics
A graphics context to measure against.
text
The text to measure.
font
The font it will be drawn in.

Returns. The size the text occupies.

OnDrawItem

protected override void OnDrawItem(DrawItemEventArgs e)

Refer to base class documentation.

OnGotFocus

protected override void OnGotFocus(EventArgs e)

Refer to base class documentation.

OnHandleCreated

protected override void OnHandleCreated(EventArgs e)

Refer to base class documentation.

OnKeyPress

protected override void OnKeyPress(KeyPressEventArgs e)

Refer to base class documentation.

OnLostFocus

protected override void OnLostFocus(EventArgs e)

Refer to base class documentation.

OnMouseEnter

protected override void OnMouseEnter(EventArgs e)

Refer to base class documentation.

OnMouseLeave

protected override void OnMouseLeave(EventArgs e)

Refer to base class documentation.

OnPaint

protected override void OnPaint(PaintEventArgs pe)

Refer to base class documentation.

OnSelectedIndexChanged

protected override void OnSelectedIndexChanged(EventArgs e)

Refer to base class documentation.

OnSystemColorsChanged

protected override void OnSystemColorsChanged(EventArgs e)

Refer to base class documentation.

e

PaintControlWithData

protected virtual void PaintControlWithData(Graphics g, Rectangle bounds, int Index, bool isSelected, bool toEdit)

Draws the closed control for the item at the given index. Override to change how a selected item is presented on the control face.

g
The surface to draw on.
bounds
The bounds of the control face.
Index
The index of the item being shown.
isSelected
true when the control is showing a selection.
toEdit
true when the face is being drawn for editing rather than display.

RefreshPaint

protected virtual void RefreshPaint(Graphics g, Rectangle bounds, int Index, bool isSelected, bool toEdit)

Redraws the control face after the selection changes, without a full layout pass.

g
The surface to draw on.
bounds
The bounds of the control face.
Index
The index of the item being shown.
isSelected
true when the control is showing a selection.
toEdit
true when the face is being drawn for editing rather than display.

SetData

protected virtual void SetData()

Refreshes the text drawn on the closed control from the current selection. The base handles the flat display style; a derived combo box overrides it for its own item shape.

WndProc

protected override void WndProc(ref Message m)

Refer to base class documentation.

Fields

DropDownButtonWidth

protected const int DropDownButtonWidth

Width in pixels of the drop-down button at the right-hand end of the control.