views:

2334

answers:

2

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.

A: 

in your string you could use the \t control char (tab) to tab out the values, although some more string-manip might need to be done to work out how many tabs you need to put in the string.

Edit: for vb.net see the controlchars class

Pondidum
\t's show up as little boxes instead of tabs, as do all the control characters
Malfist
+4  A: 

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".

devio
The third example helped the most
Malfist