Click here to Skip to main content
13,260,113 members (49,036 online)
Rate this:
Please Sign up or sign in to vote.
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 8-Aug-12 20:53pm
Reji Ab605
Updated 8-Aug-12 20:55pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You can Use Fixed Size Font for Display for eg: Courier New.
aarti meswania 9-Aug-12 6:52am
very true answer, 5 points!
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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!

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.171114.1 | Last Updated 9 Aug 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100