I want to do some visual changes on listbox items so i set DrawMode to “OwnerDrawFixed”
i want the text to be the middle of the item
vertivally it was easy by doing this:
private void listTypes_DrawItem(object sender, DrawItemEventArgs e)
{
e.DrawBackground();
e.Graphics.DrawString(listTypes.Items[e.Index].ToString(),
e.Font, Brushes.Black, e.Bounds.Left, e.Bounds.Top + e.Bounds.Height/4
, StringFormat.GenericDefault);
e.DrawFocusRectangle();
}
but to center the text horizentally i need to know the text width
how to get it or is there a better way to do this
You can try with code