///<summary>
///通过继承 ComboCellType 实现
///</summary>
public class ImageCombo : FarPoint.Win.
Spread.CellType.ComboBoxCellType
{
public override void PaintCell(Graphics g, Rectangle r, FarPoint.Win.
Spread.Appearance appearance, object value, bool isSelected, bool isLocked, float zoomFactor)
{
if (value != null)
{
int ind =0;
for (int i = 0; i <base.Items.Length; i++)
{
if (base.Items[i] == value.ToString())
{
ind = i;
break;
}
}
Image img = base.ImageList.Images[ind];
g.DrawImage(img, newRectangle(newPoint(r.X, r.Y), newSize(20, 20)));
g.DrawString(value.ToString(), appearance.Font, newSolidBrush(Color.Black), newPointF(r.X + 20, r.Y-10 + 10));
ControlPaint.DrawComboButton(g, newRectangle(r.Right - 17, r.Y, 17, r.Height), ButtonState.Normal);
}
else
{
base.PaintCell(g, r, appearance, value, isSelected, isLocked, zoomFactor);
}
}
}
该代码运行时的效果图: