/// <summary> /// Paints the selected node in the control. /// </summary> /// <param name="e"></param> protected override void OnPaintContent(DropDownPaintEventArgs e) { base.OnPaintContent(e); Image img = GetNodeImage(selectedNode); string text = (selectedNode != null) ? ((showPath) ? Path : selectedNode.Text) : nullValue; Rectangle imgBounds = (img == null) ? new Rectangle(1, 0, 0, 0) : new Rectangle(4, e.Bounds.Height / 2 - img.Height / 2, img.Width, img.Height); Rectangle txtBounds = new Rectangle(imgBounds.Right, 0, e.Bounds.Width - imgBounds.Right - 3, e.Bounds.Height); if (img != null) { e.Graphics.DrawImage(img, imgBounds); } TextRenderer.DrawText(e.Graphics, text, Font, txtBounds, ForeColor, TEXT_FORMAT_FLAGS); // focus rectangle if (Focused && ShowFocusCues && !DroppedDown) { e.DrawFocusRectangle(); } }
/// <summary> /// Paints the selected node in the control. /// </summary> /// <param name="e"></param> protected override void OnPaintContent(DropDownPaintEventArgs e) { base.OnPaintContent(e); Image img = GetNodeImage(selectedNode); string text = (selectedNode != null) ? ((showPath) ? Path : selectedNode.Text) : nullValue; Rectangle imgBounds = (img == null) ? new Rectangle(1,0,0,0) : new Rectangle(4, e.Bounds.Height / 2 - img.Height / 2, img.Width, img.Height); Rectangle txtBounds = new Rectangle(imgBounds.Right, 0, e.Bounds.Width - imgBounds.Right - 3, e.Bounds.Height); if (img != null) e.Graphics.DrawImage(img, imgBounds); TextRenderer.DrawText(e.Graphics, text, Font, txtBounds, ForeColor, TEXT_FORMAT_FLAGS); // focus rectangle if (Focused && ShowFocusCues && !DroppedDown) e.DrawFocusRectangle(); }