using
System;
using System.Windows.Forms;
using System.Windows.Forms.Design;
using System.Drawing;
namespace Mengxianhui.ComboBoxEx
... {
class ComboBoxEx : ComboBox
...{
private ImageList imageList;
public ImageList ImageList
...{
get ...{ return imageList;}
set ...{imageList = value;}
}
public ComboBoxEx()
...{
DrawMode = DrawMode.OwnerDrawFixed;
}
protected override void OnDrawItem(DrawItemEventArgs ea)
...{
ea.DrawBackground();
ea.DrawFocusRectangle();
ComboBoxExItem item;
Size imageSize = imageList.ImageSize;
Rectangle bounds = ea.Bounds;
try
...{
item = (ComboBoxExItem)Items[ea.Index];
if (item.ImageIndex != -1)
...{
imageList.Draw(ea.Graphics, bounds.Left, bounds.Top,
item.ImageIndex);
ea.Graphics.DrawString(item.Text, ea.Font, new
SolidBrush(ea.ForeColor), bounds.Left+
using System.Windows.Forms;
using System.Windows.Forms.Design;
using System.Drawing;
namespace Mengxianhui.ComboBoxEx
... {
class ComboBoxEx : ComboBox
...{
private ImageList imageList;
public ImageList ImageList
...{
get ...{ return imageList;}
set ...{imageList = value;}
}
public ComboBoxEx()
...{
DrawMode = DrawMode.OwnerDrawFixed;
}
protected override void OnDrawItem(DrawItemEventArgs ea)
...{
ea.DrawBackground();
ea.DrawFocusRectangle();
ComboBoxExItem item;
Size imageSize = imageList.ImageSize;
Rectangle bounds = ea.Bounds;
try
...{
item = (ComboBoxExItem)Items[ea.Index];
if (item.ImageIndex != -1)
...{
imageList.Draw(ea.Graphics, bounds.Left, bounds.Top,
item.ImageIndex);
ea.Graphics.DrawString(item.Text, ea.Font, new
SolidBrush(ea.ForeColor), bounds.Left+