|
|
Title | Set tabs in a ListBox in VB .NET |
Description | This example shows how to set tabs in a ListBox in VB .NET. |
Keywords | ListBox, tabs, VB .NET |
Categories | Controls, VB.NET |
|
|
When the program starts, it creates an array containing the tab stops' positions. It then uses the SendMessage API function to send the TextBox the LB_SETTABSTOPS message, passing it the tab stop array.
|
|
Private Declare Function SendMessage Lib "user32" Alias _
"SendMessageA" (ByVal hwnd As IntPtr, ByVal wMsg As _
Integer, ByVal wParam As Integer, ByRef lParam As _
Integer) As Integer
Private Const LB_SETTABSTOPS As Integer = &H192
Private Sub Form1_Load(ByVal sender As System.Object, ByVal _
e As System.EventArgs) Handles MyBase.Load
' Define the tabs.
Dim tabs() As Integer = {20, 130}
SendMessage(ListBox1.Handle, LB_SETTABSTOPS, 2, tabs(0))
ListBox1.Items.Add("Bacon Burger" & vbTab & "3.00")
ListBox1.Items.Add(vbTab & "Tomato" & vbTab & "0.15")
ListBox1.Items.Add(vbTab & "Extra Cheese" & vbTab & _
"0.20")
ListBox1.Items.Add("Large Fries" & vbTab & "0.99")
ListBox1.Items.Add("Medium Softdrink" & vbTab & "1.05")
ListBox1.Items.Add("")
ListBox1.Items.Add("Subtotal" & vbTab & "5.39")
ListBox1.Items.Add("Tax" & vbTab & vbTab & "0.38")
ListBox1.Items.Add("Total" & vbTab & vbTab & "5.77")
End Sub
|
|
 |
|
|
|