I'm working on a setting for my app to change color for the controls (basically, i want to create a dark theme). I'm almost done with it but I noticed this issue.
I'm changing the comboboxes draw mode from Normal to OwnerDrawFixed so I can change the backcolor and forecolor. Changing Draw Mode, however, makes the letters in the combobox appear different: not only the text gets slightly moved up-right (1 pixel, no big deal), some letters get larger or take more space between one another.
In the pic i uploaded you can check the comboboxes are exactly the same, the content though changes. Is there a way to prevent this? I could get around this handling differently the form area, but before that i'd rather avoid the issue in the first place.
No big deal with the code, as I said I'm changing the comboboxes draw mode from Normal to OwnerDrawFixed and I'm setting backcolor and forecolor, nothing else.
There's also a handler for the dropdown list, but it should involve only that, i suppose. If you think the problem could be there, just tell me, this is it (it's used for every combobox):
I'm changing the comboboxes draw mode from Normal to OwnerDrawFixed so I can change the backcolor and forecolor. Changing Draw Mode, however, makes the letters in the combobox appear different: not only the text gets slightly moved up-right (1 pixel, no big deal), some letters get larger or take more space between one another.
In the pic i uploaded you can check the comboboxes are exactly the same, the content though changes. Is there a way to prevent this? I could get around this handling differently the form area, but before that i'd rather avoid the issue in the first place.
No big deal with the code, as I said I'm changing the comboboxes draw mode from Normal to OwnerDrawFixed and I'm setting backcolor and forecolor, nothing else.
There's also a handler for the dropdown list, but it should involve only that, i suppose. If you think the problem could be there, just tell me, this is it (it's used for every combobox):
C#:
private void darktheme_DrawItem(object sender, DrawItemEventArgs e)
{
if (e.Index >= 0)
{
var combo = sender as ComboBox;
int index = e.Index;
var brush = new SolidBrush(Color.FromArgb(220, 220, 220));
e.DrawBackground();
e.Graphics.DrawString(combo.Items[index].ToString(), e.Font, brush, e.Bounds, StringFormat.GenericDefault);
e.DrawFocusRectangle();
}
}