In This Article

ColorListBox Class

Provides a ListBox that shows Color objects.

public class ColorListBox : ListBox, IDisposable, IDpiAwareElement
Inheritance:
object MarshalByRefObject Component Control ListControl ListBox object
Implements:
IDisposable IDpiAwareElement

Constructors

ColorListBox()

Initializes a new instance of the ColorListBox class.

public ColorListBox()

Remarks

The default constructor initializes all fields to their default values.

Properties

ColorSet

Gets the ColorListBoxColorSet that indicates the color set that is loaded.

public ColorListBoxColorSet ColorSet { get; set; }

Property Value

ColorListBoxColorSet:

The ColorListBoxColorSet that indicates the color set that is loaded.

DrawMode

Gets or sets the drawing mode for the control.

[Browsable(false)]
public DrawMode DrawMode { get; set; }

Property Value

DrawMode:

One of the DrawMode values representing the mode for drawing the items of the control. The default is DrawMode.Normal.

Exceptions

Type Condition
InvalidEnumArgumentException

The value assigned to the property is not a member of the DrawMode enumeration.

ArgumentException

A multicolumn ListBox cannot have a variable-sized height.

ItemHeight

Gets the height of an item in the ColorListBox.

[Browsable(false)]
public int ItemHeight { get; set; }

Property Value

int:

The height, in pixels, of an item in the control.

Remarks

The height of items in this control is automatically determined based on current device DPI. Setting this value will have no effect.

SelectedColor

Gets or sets the selected color in the list.

[Browsable(false)]
public Color SelectedColor { get; set; }

Property Value

Color:

The selected Color in the list.

Methods

InitializeColors(Color[])

Initializes the list using the specified array of Color objects.

public void InitializeColors(Color[] colors)
Parameter Type Description
colors Color[]

An array of Color objects with which to initialize the list.

OnDrawItem(DrawItemEventArgs)

Occurs when an item needs to be drawn.

protected override void OnDrawItem(DrawItemEventArgs e)
Parameter Type Description
e DrawItemEventArgs

A DrawItemEventArgs that contains the event data.

OnFontChanged(EventArgs)

Occurs when then font property is changed.

protected override void OnFontChanged(EventArgs e)
Parameter Type Description
e EventArgs

An EventArgs that contains the event data.

OnMeasureItem(MeasureItemEventArgs)

Occurs when an item needs to be measured.

protected override void OnMeasureItem(MeasureItemEventArgs e)
Parameter Type Description
e MeasureItemEventArgs

A DrawItemEventArgs that contains the event data.

WndProc(ref Message)

Occurs when a message is sent to the control.

protected override void WndProc(ref Message m)
Parameter Type Description
m Message

Information about the message.

Inherited Members

Extension Methods