protected override void OnDrawItem(DrawItemEventArgs e) { e.DrawBackground(); e.DrawFocusRectangle(); if (Items[e.Index].GetType() == typeof(GListBoxItem)) { try { Rectangle bounds = e.Bounds; GListBoxItem item = (GListBoxItem)Items[e.Index]; if (item.ImageIndex != -1) { Size imageSize = ImageList.ImageSize; ImageList.Draw(e.Graphics, bounds.Left, bounds.Top, item.ImageIndex); e.Graphics.DrawString(item.TextWithCounter, e.Font, new SolidBrush(e.ForeColor), bounds.Left + imageSize.Width, bounds.Top); } else { e.Graphics.DrawString(item.TextWithCounter, e.Font, new SolidBrush(e.ForeColor), bounds.Left, bounds.Top); } } catch { DrawStringItem(e); } } else { DrawStringItem(e); } base.OnDrawItem(e); }
public GListBoxItem FindItem(string key) { foreach (object o in Items) { if (o.GetType() == typeof(GListBoxItem)) { GListBoxItem gi = (GListBoxItem)o; if (gi.Text.Equals(key)) { return(gi); } } } return(null); }