strings to have equal lengths

  • Thread starter Thread starter andrews
  • Start date Start date
A

andrews

I have to add several strings to a listbox.
add str1 & str2
add str3 & str4 (new line)
.....

the strings str1 and str2 have different lengths and i want that the
strings str2 and str4 are aligned in the listbox
I tried to add spaces to shorter strings to have the same lengths for
str1 and str2 but there is no alignment for str2 and str4
Take the spaces more place then other chars or is the fontsize importent?
And what can I do?
Thanks for any response
 
Sorry,
But I find that the font Courier New makes the job.
Maybe there are other solutions?
 
No there is no other way as using a ( monospace ) fixed width font like
Courier , Courier new , Comic sans , Andale mono , Fixedsys etc etc etc

hth

Michel
 
Dans : Michel Posseth [MCP] écrivait :
No there is no other way as using a ( monospace ) fixed width font
like Courier , Courier new , Comic sans , Andale mono , Fixedsys etc
etc etc

No other simple way.
But you can draw list items with your own code if you want.

MSDN Library says :
Typically, Windows handles the task of drawing the items to display in
the ListBox. You can use the DrawMode property, and handle the
MeasureItem and DrawItem events so you can override the automatic
drawing that Windows provides and draw the items yourself. You can use
owner-drawn ListBox controls to display variable-height items, images,
or a different color or font for the text of each item in the list. The
HorizontalExtent property, GetItemHeight, and GetItemRectangle also help
you draw your own items.

Sorry, I didn't do it for a ListBox so I don't have a sample code to
provide
 
Thanks for the information but the solution with the monospace is likely
the most simple, so I use it
 
Back
Top