Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Formatting text for a combobox, C#

I have three values I need to align in a dropdown box. How can I do this? I've been trying this: String.Format("{0,-30}{1,-15}{2,-10}{3,-8}", new object[] { cusJob, service, username, time }); But that leaves it uneven because it's not a monospaced font. I don't really want to use a monospaced font and I've seen applications align it before so how can I do it?

Thanks.

like image 693
Malfist Avatar asked Oct 15 '22 17:10

Malfist


1 Answers

You need to set the DropDownList's DrawMode to OwnerDrawFixed and render the items in the DrawItem event handler.

Examples are here and here and here, but there are lot more to be found on the web, if you search for "dropdownlist ownerdraw columns drawmode".

like image 191
devio Avatar answered Oct 20 '22 18:10

devio