Hi,
I have a problem with my combobox list, I want to put a little image beside each item on my list so I use the event DrawItem.
The problem is when the combobox drop down, the list is blank and I only see the description when my mouse is on the item.
I can't figure out what I'm doing wrong.
private void cboStandard_DrawItem(object sender, DrawItemEventArgs e)
{
cbo_DrawItem((ComboBox)sender, e, this.ilStandard);
}
//
//
private void cbo_DrawItem(ComboBox cbo, DrawItemEventArgs e, ImageList img)
{
if (e.Index < 0) return;
if (cbo.SelectedIndex < 0) return;
string text = "-";
if (cbo.SelectedIndex > -1)
{
UTIL.CfgStd Blk = Blk = (UTIL.CfgStd)UT.aStandard[cbo.SelectedIndex];
text = Blk.Des;
}
e.DrawBackground();
using (SolidBrush br
= new SolidBrush
(e
.ForeColor)) { e.Graphics.DrawString(text, e.Font, br, e.Bounds); }
if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
e.DrawFocusRectangle();
e.DrawBackground();
e.DrawFocusRectangle();
string s = "";
if (e.Index > -1 && img.Images.Count > e.Index)
{
e
.Graphics.DrawImage(img
.Images[e
.Index],
new PointF
(e
.Bounds.X, e
.Bounds.Y)); s = " " + ((UTIL.CfgStd)UT.aStandard[cbo.SelectedIndex]).Des;
e
.Graphics.DrawString(s, e
.Font, Brushes
.Black,
new Point
(e
.Bounds.X, e
.Bounds.Y)); }
}