OK VB wizards...
I need to find the longest text in the listbox.
I a finding that ListBx.List is not a vaide property:
The code:
Sub AddHScrollForListBox(ListBx As ListBox)
Dim i As Integer, intGreatestLen As Integer, lngGreatestWidth As Long
'Find Longest Text in ListBox
For i = 0 To ListBx.ListCount - 1
If Len(ListBx.List(i)) > Len(ListBx.List(intGreatestLen)) Then
intGreatestLen = i
End If
Next i
'Get Twips
lngGreatestWidth = ListBx.Parent.TextWidth(ListBx.List(intGreatestLen) + Space(2))
'Space(1) is used to prevent the last Character from being cut off
'Convert to Pixels
lngGreatestWidth = lngGreatestWidth \ Screen.TwipsPerPixelX
'Use api to add scrollbar
SendMessage ListBx.hWnd, LB_SETHORIZONTALEXTENT, lngGreatestWidth, 0
End Sub
Any ideas?
Thanks
Art Lorenzini
SD
Posted by: dbalorenzini@yahoo.com
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (1) |
Tidak ada komentar:
Posting Komentar