Skip to content

Commit

Permalink
fix weird looks for long texts in StylableComboBox because of wrapped…
Browse files Browse the repository at this point in the history
… text (#62)
  • Loading branch information
wolframhaussig authored Feb 27, 2024
1 parent 7b5e5f2 commit c84fb2c
Showing 1 changed file with 4 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,35 +187,16 @@ private Rectangle getDownRectangle()
}

private void drawComboBox(Graphics graphics)
{
Rectangle drawArea = ClientRectangle;
using SolidBrush backBrush = new(BackColor);
using SolidBrush foreBrush = new(ForeColor);

using StringFormat stringFormat = new()
{
LineAlignment = StringAlignment.Center
};

graphics.FillRectangle(backBrush, drawArea);

Rectangle textDrawArea = drawArea;
textDrawArea.X += 4;
graphics.DrawString(
Text,
Font,
foreBrush,
textDrawArea,
stringFormat);
{
TextRenderer.DrawText(graphics, Text, Font, ClientRectangle, ForeColor, BackColor, TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter | TextFormatFlags.WordEllipsis);

ComboBoxRenderer.DrawDropDownButton(graphics, getDownRectangle(), System.Windows.Forms.VisualStyles.ComboBoxState.Normal);

Rectangle borderRectangle = drawArea;
graphics.DrawRectangle(_borderColorPen, borderRectangle);
graphics.DrawRectangle(_borderColorPen, ClientRectangle);

if (Focused && ShowFocusCues)
{
ControlPaint.DrawFocusRectangle(graphics, borderRectangle);
ControlPaint.DrawFocusRectangle(graphics, ClientRectangle);
}
}
}

0 comments on commit c84fb2c

Please sign in to comment.