This class encapsulates the event arguments for owner-draw events.
CheckedListBox, ComboBox,
ListBox, MenuItem,
StatusBar, and TabControl
controls all support owner draw features, if you set their
DrawMode property appropriately.
When you handle an item's
DrawItem event, you can retrieve information about
the BackColor, ForeColor, and
Font of the item to be painted. You can also get
the System.Drawing.Graphics surface on which to
paint the item, and the Bounds of the item to draw
on that surface.
Other properties specify the Index of the item to
paint, and the State of the item from the
DrawItemState enumeration.
Two utility methods will DrawBackground() or
DrawFocusRectangle() imagery.
public class DrawItemEventArgs : EventArgs {
// Public Constructors
public DrawItemEventArgs(System.Drawing.Graphics graphics, System.Drawing.Font font,
System.Drawing.Rectangle rect, int index, DrawItemState state);
public DrawItemEventArgs(System.Drawing.Graphics graphics, System.Drawing.Font font,
System.Drawing.Rectangle rect, int index, DrawItemState state, System.Drawing.Color foreColor,
System.Drawing.Color backColor);
// Public Instance Properties
public Color BackColor{get; }
public Rectangle Bounds{get; }
public Font Font{get; }
public Color ForeColor{get; }
public Graphics Graphics{get; }
public int Index{get; }
public DrawItemState State{get; }
// Public Instance Methods
public virtual void DrawBackground();
public virtual void DrawFocusRectangle();
}