Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
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 19:53pm
Reji Ab564
Edited 8-Aug-12 19:55pm
v4
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You can Use Fixed Size Font for Display for eg: Courier New.
  Permalink  
Comments
aarti meswania at 9-Aug-12 6:52am
   
very true answer, 5 points!
:)
Rate this: bad
good
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!
  Permalink  
v2

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 480
1 OriginalGriff 258
2 Bhavik_Patel 170
3 PhilLenoir 155
4 Richard Deeming 140
0 Sergey Alexandrovich Kryukov 8,688
1 OriginalGriff 7,237
2 CPallini 2,598
3 Richard MacCutchan 2,080
4 Abhinav S 1,888


Advertise | Privacy | Mobile
Web03 | 2.8.140827.1 | Last Updated 9 Aug 2012
Copyright © CodeProject, 1999-2014
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