By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,594 Members | 2,059 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,594 IT Pros & Developers. It's quick & easy.

help with listbox alignt eg. {0,-1}

P: 1
Hi, my problem is am doin a listbox aligning different data like name space number space whatever so i cant get the lists straight... How do i do that??
Dec 10 '07 #1
Share this Question
Share on Google+
1 Reply


devonknows
100+
P: 137
Hi, if im correct in thinking your trying to make columns? yes? The reason by putting space 'chr(32)' wont work is each letter has its own dimensions etc etc you get the idea so nothing can line up directly.

Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2. Private Const LB_SETTABSTOPS = &H192
  3. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As _
  4.         Long, ByVal wParam As Long, lParam As Any) As Long 
  5. '//Change OBorder to how many colums you require
  6. Const OBorder = 1
  7. Private Tabulator(1 To OBorder) As Long
  8.  
  9. Private Sub Form_Load()
  10.     '//If You Change OBorder higher than one than you need to set the left values of the 
  11.     '//Tabulator's array (Ive Inserted a few commented for an example) - 
  12.     Tabulator(1) = 50
  13.     'Tabulator(2) = 150
  14.     'Tabulator(3) = 250
  15.     '//This Will Call the function that will set up the tabstops
  16.     Call MakeList 'This Subroutine sets the listbox up
  17. End Sub
  18.  
  19. Private Sub MakeList(lstbx as ListBox)
  20.   ' Clear the ListBox, set new tab stops and add values
  21.   lstbx.Clear
  22.  
  23.   SendMessage lstbx.hWnd, _
  24.     LB_SETTABSTOPS, OBorder, Tabulator(1)
  25. End Sub
  26.  
Every column you add (OBorder) you will have to add vbTab inbetween for example if you set OBorder to 3 (4 Columns) you would use this...
Expand|Select|Wrap|Line Numbers
  1. List1.AddItem "Column1 Text" & vbTab & "Column2 Text" & vbTab & "Column3 Text" & vbTab & "Column4 Text"
Which Would Look Like This:
(Ignore the ____, Just there to show the space between columns)

Column1 Text ____ Column2 Text ____ Column3 Text ____ Column4 Text


Hope This Helps ya
Devon
Dec 10 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.