|
Tipp 0153
|
Spalten in einer ListBox
|
|
|
Autor/Einsender: Datum: |
|
Stephan Liebler 02.11.2001 |
|
Entwicklungsumgebung: |
|
VB 5 |
|
|
In einer ListBox ist es durchaus möglich, auch mehrspaltige Ausgaben vorzunehmen.
Da durch das einfache Einfügen eines oder mehrerer Tabs mit nur VB-Mitteln, es kaum oder
nur sehr schwer möglich ist, exakte Spalten zu bekommen, hilft hier die Universal-API-Funktion
SendMessage wieder einmal weiter.
|
|
|
Option Explicit
Private Declare Function SendMessage Lib "user32" Alias _
"SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Any) As Long
Const LB_SETTABSTOPS = &H192
Const OGrenze = 4
Dim Tabulator(1 To OGrenze) As Long
Dim Text1 As String, Text2 As String
Private Sub Form_Load()
Tabulator(1) = 50
Tabulator(2) = 100
Tabulator(3) = 150
Tabulator(4) = 200
Combo1.AddItem "2 Spalten"
Combo1.AddItem "3 Spalten"
Combo1.AddItem "4 Spalten"
Combo1.AddItem "5 Spalten"
Combo1.ListIndex = 0
End Sub
Private Sub Combo1_Click()
Dim x As Integer
Dim pos As Integer
Dim stelle As Integer
List1.Clear
SendMessage List1.hwnd, LB_SETTABSTOPS, OGrenze, Tabulator(1)
Text1 = "Uwe" & vbTab & "Wilhelm" & vbTab & "Karl-Heinz" & _
vbTab & "Michael" & vbTab & "Ute" & vbTab
For x = 1 To Len(Text1)
pos = InStr(pos + 1, Text1, vbTab, vbTextCompare)
If stelle = Combo1.ListIndex + 1 Then
Text1 = Left$(Text1, pos - 1)
stelle = 0
pos = 0
Exit For
End If
stelle = stelle + 1
Next
For x = 1 To 6 Step 2
List1.AddItem Text1
Next
End Sub
|
|
|
|
|
Windows-Version |
95 |
|
|
98/SE |
|
|
ME |
|
|
NT |
|
|
2000 |
|
|
XP |
|
|
Vista |
|
|
Win
7 |
|
|
|
VB-Version |
VBA 5 |
|
|
VBA 6 |
|
|
VB 4/16 |
|
|
VB 4/32 |
|
|
VB 5 |
|
|
VB 6 |
|
|
|
|
Download (2,4 kB)
|
Downloads bisher: [ 3731 ]
|
|
|