Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleSet tabs in a ListBox to make items line up nicely
KeywordsListBox, tab, tabs, columns
CategoriesControls
 
Use the SendMessage API function to send the LB_SETTABSTOPS message to the ListBox. This functions takes as parameters the number of tabs and an array holding the tabs' positions in pixels.
 
Private Sub Form_Load()
Dim tabs(1 To 2) As Long

    tabs(1) = 20
    tabs(2) = 130

    ' Set the tabs.
    SendMessage List1.hwnd, LB_SETTABSTOPS, 2, tabs(1)
    
    ' Enter some values.
    List1.AddItem "Bacon Burger" & vbTab & "3.00"
    List1.AddItem vbTab & "Tomato" & vbTab & "0.15"
    List1.AddItem vbTab & "Extra Cheese" & vbTab & "0.20"
    List1.AddItem "Large Fries" & vbTab & "0.99"
    List1.AddItem "Medium Softdrink" & vbTab & "1.05"
    List1.AddItem ""
    List1.AddItem "Subtotal" & vbTab & "5.39"
    List1.AddItem "Tax" & vbTab & vbTab & "0.38"
    List1.AddItem "Total" & vbTab & vbTab & "5.77"
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated