Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I just want to populate list box with strings seperated by fixed length as shown below.

abc dddee
abd efgr

The problem is the second column doesn't align properly in some cases because of the size difference of the characters I used as shown below. I am not using a printer friendly font.

abc dddee
nlk efgr

If I measure the size of "abc" and "nlk" . It is different in point measurement. If I manage to put spaces in points or any other way to adjust it then I may able to align the second column properly.

How to make it work? Thanks
Posted
Updated 8-Aug-12 19:55pm
v4

You can Use Fixed Size Font for Display for eg: Courier New.
 
Share this answer
 
Comments
Aarti Meswania 9-Aug-12 6:52am    
very true answer, 5 points!
:)
Use a different font or use tabs, at least it will adapt a little bit the differences.

You can always try to get the measurement of the strings given the used font and then add spaces accordingly.

A sample of what I mean can be found here[^] in C#.

Here[^] in VB.

I guess this will be a good starting point for you.

PS: I've used google with this search string: get width of string using non fixed font

Good luck!
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900