HypernovaDesktop Components · docs
Binarymission
WinFormsColor Picker › BinaryColorPickerComboBox

BinaryColorPickerComboBox

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

A ComboBox styled ColorPicker control emulating the VS.NET color picker.

public class BinaryColorPickerComboBox : System.Windows.Forms.ComboBox

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

Members at a glance

BinaryColorPickerComboBoxInitializes a new instance of BinaryColorPickerComboBox 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.
CustomColorRectangleBorderStyleGets or sets the Border style ( i.e. Border3DStyle )for painting the borders of custom color boxes in the Custom colors tab page of the dropdown color control.
CustomControlBorderColorGets or sets the Color value for painting the Control's border.
CustomPaintingColorGets or sets the Color value for painting the Control.
RightToLeftRightToLeft is currently not supported. Planned for future release.
SelectedColorGets or sets the currently selected color in the ColorPicker combobox control.
ShowBorderAlwaysGets or sets whether the control will always have its border displayed, even when the control is not currently in focus.
ShowColorNameIfKnownColorGets or sets whether to show the color name in the combobox text area, if the chosen/selected/set color is a known color (refer to IsKnownColor for more details).
DisposeReleases the resources held by this BinaryColorPickerComboBox.
DrawComboBoxFaceDraws the closed control: the selected color, its text and the drop-down button.
DrawComboBoxFaceBackgroundDraws the background of the closed control. Override to change the control background without taking over the swatch, the text and the button.
DrawDisabledFaceDraws the control in its disabled form.
DrawDisabledFaceBackgroundDraws the background behind the disabled control. Override to change the disabled look without taking over the rest of the painting.
DrawListItemDraws one row of the drop-down list: its background, its color swatch and its text.
DrawListItemBackgroundDraws the background of one row of the drop-down list. Override to change the row background without taking over the swatch and the text.
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.
OnDrawItemRaises the DrawItem event. BinaryColorPickerComboBox overrides it so the control's own handling runs alongside the base behavior.
OnGotFocusRaises the GotFocus event. BinaryColorPickerComboBox overrides it so the control's own handling runs alongside the base behavior.
OnHandleCreatedRaises the HandleCreated event. BinaryColorPickerComboBox overrides it so the control's own handling runs alongside the base behavior.
OnKeyPressRaises the KeyPress event. BinaryColorPickerComboBox overrides it so the control's own handling runs alongside the base behavior.
OnLostFocusRaises the LostFocus event. BinaryColorPickerComboBox overrides it so the control's own handling runs alongside the base behavior.
OnMouseEnterRaises the MouseEnter event. BinaryColorPickerComboBox overrides it so the control's own handling runs alongside the base behavior.
OnMouseLeaveRaises the MouseLeave event. BinaryColorPickerComboBox overrides it so the control's own handling runs alongside the base behavior.
OnPaintRaises the Paint event. BinaryColorPickerComboBox overrides it so the control's own handling runs alongside the base behavior.
OnSelectedIndexChangedRaises the SelectedIndexChanged event. BinaryColorPickerComboBox overrides it so the control's own handling runs alongside the base behavior.
SetFontHeightSets the item height of the drop-down list from a measured font height.
WndProcProcesses the Windows messages sent to this control's window.
SelectedColorChangedFires when the SelectedColor property changes or when the current color is changed by the user (or in the code) by selecting a new color value form the dropdown colorpicker.
DropDownButtonWidthWidth in pixels of the drop-down button at the right-hand end of the control.

Constructors

BinaryColorPickerComboBox

public BinaryColorPickerComboBox()

Initializes a new instance of BinaryColorPickerComboBox 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.

CustomColorRectangleBorderStyle

public Border3DStyle CustomColorRectangleBorderStyle

Gets or sets the Border style ( i.e. Border3DStyle )for painting the borders of custom color boxes in the Custom colors tab page of the dropdown color control.

Set this property with one of the valid border styles from the Border3DStyle list.

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.

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.

RightToLeft

public override RightToLeft RightToLeft

RightToLeft is currently not supported. Planned for future release.

SelectedColor

public Color SelectedColor

Gets or sets the currently selected color in the ColorPicker combobox control.

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.

ShowColorNameIfKnownColor

public bool ShowColorNameIfKnownColor

Gets or sets whether to show the color name in the combobox text area, if the chosen/selected/set color is a known color (refer to IsKnownColor for more details).

Methods

Dispose

protected override void Dispose(bool disposing)

Releases the resources held by this BinaryColorPickerComboBox.

disposing
true when called from Dispose; false when called from the finalizer.

DrawComboBoxFace

protected void DrawComboBoxFace(Graphics g, Rectangle bounds, int index, bool isSelected, bool hasFocus)

Draws the closed control: the selected color, its text and the drop-down button.

g
The surface to draw on.
bounds
The bounds of the control face.
index
The index of the selected item.
isSelected
true when the control is showing a selection.
hasFocus
true when the control has the focus.

DrawComboBoxFaceBackground

protected virtual void DrawComboBoxFaceBackground(Graphics g, Rectangle bounds, int Index, bool isSelected, bool hasFocus)

Draws the background of the closed control. Override to change the control background without taking over the swatch, the text and the button.

g
The surface to draw on.
bounds
The bounds of the control face.
Index
The index of the selected item.
isSelected
true when the control is showing a selection.
hasFocus
true when the control has the focus.

DrawDisabledFace

protected void DrawDisabledFace()

Draws the control in its disabled form.

DrawDisabledFaceBackground

protected virtual void DrawDisabledFaceBackground()

Draws the background behind the disabled control. Override to change the disabled look without taking over the rest of the painting.

DrawListItem

protected void DrawListItem(Graphics g, Rectangle bounds, int index, bool isSelected, bool hasFocus)

Draws one row of the drop-down list: its background, its color swatch and its text.

g
The surface to draw on.
bounds
The bounds of the row.
index
The index of the item being drawn.
isSelected
true when the row is the selected one.
hasFocus
true when the row also has the focus rectangle.

DrawListItemBackground

protected virtual void DrawListItemBackground(Graphics g, Rectangle bounds, int Index, bool isSelected, bool hasFocus)

Draws the background of one row of the drop-down list. Override to change the row background without taking over the swatch and the text.

g
The surface to draw on.
bounds
The bounds of the row.
Index
The index of the item being drawn.
isSelected
true when the row is the selected one.
hasFocus
true when the row also has the focus rectangle.

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)

Raises the DrawItem event. BinaryColorPickerComboBox overrides it so the control's own handling runs alongside the base behavior.

e
The data for the event.

OnGotFocus

protected override void OnGotFocus(EventArgs e)

Raises the GotFocus event. BinaryColorPickerComboBox overrides it so the control's own handling runs alongside the base behavior.

e
The data for the event.

OnHandleCreated

protected override void OnHandleCreated(EventArgs e)

Raises the HandleCreated event. BinaryColorPickerComboBox overrides it so the control's own handling runs alongside the base behavior.

e
The data for the event.

OnKeyPress

protected override void OnKeyPress(KeyPressEventArgs e)

Raises the KeyPress event. BinaryColorPickerComboBox overrides it so the control's own handling runs alongside the base behavior.

e
The data for the event.

OnLostFocus

protected override void OnLostFocus(EventArgs e)

Raises the LostFocus event. BinaryColorPickerComboBox overrides it so the control's own handling runs alongside the base behavior.

e
The data for the event.

OnMouseEnter

protected override void OnMouseEnter(EventArgs e)

Raises the MouseEnter event. BinaryColorPickerComboBox overrides it so the control's own handling runs alongside the base behavior.

e
The data for the event.

OnMouseLeave

protected override void OnMouseLeave(EventArgs e)

Raises the MouseLeave event. BinaryColorPickerComboBox overrides it so the control's own handling runs alongside the base behavior.

e
The data for the event.

OnPaint

protected override void OnPaint(PaintEventArgs pe)

Raises the Paint event. BinaryColorPickerComboBox overrides it so the control's own handling runs alongside the base behavior.

pe
The data for the event.

OnSelectedIndexChanged

protected override void OnSelectedIndexChanged(EventArgs e)

Raises the SelectedIndexChanged event. BinaryColorPickerComboBox overrides it so the control's own handling runs alongside the base behavior.

e
The data for the event.

SetFontHeight

protected void SetFontHeight(int s)

Sets the item height of the drop-down list from a measured font height.

s
The height, in pixels.

WndProc

protected override void WndProc(ref Message m)

Processes the Windows messages sent to this control's window.

Events

SelectedColorChanged

public event EventHandler SelectedColorChanged

Fires when the SelectedColor property changes or when the current color is changed by the user (or in the code) by selecting a new color value form the dropdown colorpicker.

Fields

DropDownButtonWidth

protected const int DropDownButtonWidth

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