Results 1 to 3 of 3

Thread: ListBox

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2001
    Posts
    106

    ListBox

    Hi,
    I need to have 2 colmuns in a listbox......Any ideas how to do that????? Any code is great.....

  2. #2
    Megatron
    Guest
    Change the Columns property to the amount of columns you want.

  3. #3
    PowerPoster beachbum's Avatar
    Join Date
    Jul 2001
    Location
    Wollongong, NSW, Australia
    Posts
    2,274
    hi
    if u don't need proper alignment in a listbox you can just use the vbtab separators.. List1.additem "col1" & vbtab & "col2"

    If u need more accurate alignment (eg right alignment for numbers) u can try this code that i got somewhere or other. I havent used it in a prog but did see that it worked.
    Regards
    Stuart
    VB Code:
    1. Module Code:  code:
    2. Public Const LB_SETTABSTOPS As Long = &H192
    3. Public Declare Function SendMessage Lib "user32" Alias_
    4.  "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, _
    5.  ByVal wParam As Long, lParam As Any) As Long
    6.  
    7. Form Code:  code:    
    8. Public Function DoTabs(lstListBox As ListBox, TabArray() As Long)      'clear any existing tabs    
    9. Call SendMessage(List1.hWnd, LB_SETTABSTOPS, 0&, ByVal 0&)     'set list tabstops    
    10. Call SendMessage(List1.hWnd, LB_SETTABSTOPS, CLng(UBound(TabArray)), TabArray(0))
    11. End Function
    12.  
    13. Private Sub Form_Activate()  
    14. Dim Tabs(6) As Long, i As Integer          
    15. 'Set the Tab Spacing for three columns    
    16. Tabs(0) = 10    
    17. Tabs(1) = 60    
    18. Tabs(2) = 110    
    19. 'Call the Tab Setting Function    
    20. DoTabs List1, Tabs
    21. List1.AddItem vbTab & "123.45" & vbTab & "4.567" & vbTab & "8888.88"    
    22. List1.AddItem vbTab & "5.67" & vbTab & "3.000" & vbTab & "7777.99"
    23. List1.AddItem vbTab & "12.4" & vbTab & "678.9" & vbTab & "9012.34"
    24. End Sub
    Stuart Laidlaw
    Brightspark Financial Software
    http://www.gstsmartbook.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width