Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb_dotnet thread: Aligning Text Strings in ListBox


Message #1 by "Bob Rudd" <bob@p...> on Mon, 3 Mar 2003 08:44:48
Hi, have an invisible text field on your form that can grow.  Find out how 
many twips there are in a space in youre desired font.  Now, in your code, 
set the text in the text field and check the width the field is set to.  
Subtract this value from the width of twips you want the text to be in the 
listbox and divide this result by the number of twips a space takes up.  
Now you know how many spaces you need to pad out your string to get a 
certain length.  A long way round but it works.

Regards,

Phillip

> Hi All,

> I am trying to fill out the items in a listbox. I want a 1 - 40 caracter 
n> ame on the left and a 4 digit count on the right. My problem is how do 
I 
a> lign the counts vertically so that they form a neat column. I have 
tried 
p> adding the name string to 40 characters with spaces on the right, but 
t> his still leaves a ragged end to the name string. I have tried 
following 
t> his with a tab which mainly works but it can occasionally jump a tab 
p> osition depending on the characters in the name string.

> Thanks,
B> ob Rudd

  Return to Index