I am trying to draw elements that end with the * symbol in red (and delete the * symbol) and draw other elements in black.
this is my code:
private void listBox1_DrawItem(object sender, DrawItemEventArgs e) { e.DrawBackground() ; //Draw our regular background if (Microsoft.VisualBasic.Strings.Right(listBox1.Items[e.Index].ToString(), 1) == "*") { e.Graphics.DrawString(Microsoft.VisualBasic.Strings.Mid(listBox1.Items[e.Index].ToString(),1,listBox1.Items[e.Index].ToString().Length - 1), e.Font, Brushes.Red, e.Bounds); //Draw the item text in red! } else { e.Graphics.DrawString(listBox1.Items[e.Index].ToString(), e.Font, Brushes.Black, e.Bounds); //Draw the item text in its regular color } }
In addition, the DrawMode property for the box list is OwnerDrawVariable .
My code works fine when the listbox font is the default font.
But when I change the font size from 8.25 (the default size) to 14, half of the text is drawn in the list. like this: 
But with the default font size, everything is correct.
What is the problem?
source share