//Protected Methods protected virtual void defaultDraw(object value, DrawSubItemEventArgs e) { e.Graphics.DrawString(value.ToString(),e.Font,new SolidBrush(e.ForeColor),e.Bounds); }
protected virtual void OnDrawSubItem(DrawSubItemEventArgs e) { object value = this.GetItemAt(e.Index,e.SubIndex); if(DrawMode == DrawMode.Normal && Items.Count > 0) { if((value as Image) != null) e.Graphics.DrawImageUnscaled((Image)value,e.Bounds); else if((value as Bitmap) != null) { IntPtr hBmp = ((Bitmap)value).GetHbitmap(); e.Graphics.DrawImageUnscaled(Image.FromHbitmap(hBmp),e.Bounds); WinAPI.DeleteObject(hBmp); } else if((value as byte[]) != null) { try { e.Graphics.DrawImageUnscaled(Image.FromStream(new MemoryStream((byte[])value)),e.Bounds); } catch(Exception ex) { defaultDraw(value,e); } } else defaultDraw(value,e); } else if(DrawSubItem.GetInvocationList() != null) DrawSubItem.DynamicInvoke(new object[]{this,e}); }
private void drawLBSubItem(object sender,DrawSubItemEventArgs e) { if(e.SubIndex == ((MultiColumnListBox)sender).TextIndex && (e.State & DrawItemState.Selected) != DrawItemState.Selected) e.Graphics.FillRectangle(new SolidBrush(SystemColors.ControlLight),e.Bounds); e.Graphics.DrawString(((MultiColumnListBox)sender).GetItemAt(e.Index,e.SubIndex).ToString(),e.Font,new SolidBrush(e.ForeColor),e.Bounds.Left,e.Bounds.Top+2); }