private void LB_DrawItem(object sender,
DrawItemEventArgs e)
{
bool selected = (e.State & DrawItemState.Selected) ==
DrawItemState.Selected;
if (e.Index == - 1)
return;
const int Offset = 24;
var li = (ListItem) LB.Items[e.Index];
string text = li.Text;
Brush bg, fg;
if (selected)
{
bg = SystemBrushes.Highlight;
fg = SystemBrushes.HighlightText;
//fg=Brushes.Black;
}
else
{
bg = SystemBrushes.Window;
fg = SystemBrushes.WindowText;
//bg=Brushes.White;
//fg=Brushes.Black;
}
if (!selected)
{
e.Graphics.FillRectangle(bg, 0, e.Bounds.Top, e.Bounds.Width,
LB.ItemHeight);
//e.Graphics.FillRectangle (SystemBrushes.Highlight,0,e.Bounds.Top,27 ,LB.ItemHeight);
}
else
{
e.Graphics.FillRectangle(SystemBrushes.Window, Offset, e.Bounds.Top,
e.Bounds.Width - Offset, LB.ItemHeight);
e.Graphics.FillRectangle(SystemBrushes.Highlight, new Rectangle(Offset
+ 1, e.Bounds.Top + 1,
e.Bounds.Width - Offset
- 2, LB.ItemHeight - 2));
//e.Graphics.FillRectangle (SystemBrushes.Highlight,27,e.Bounds.Top,e.Bounds.Width-27 ,LB.ItemHeight);
//e.Graphics.FillRectangle (new SolidBrush(Color.FromArgb (182,189,210)),new Rectangle (1+27,e.Bounds.Top+1,e.Bounds.Width-2- ,LB.ItemHeight-2));
ControlPaint.DrawFocusRectangle(e.Graphics, new Rectangle(Offset,
e.Bounds.Top, e.Bounds.Width - Offset,
LB.ItemHeight));
}
e.Graphics.DrawString(text, e.Font, fg, Offset + 2, e.Bounds.Top + 1);
if (Images != null && li.Type != -1)
e.Graphics.DrawImage(Images.Images[li.Type], 6, e.Bounds.Top + 0);
}