When there are more items in the list box, the vertical scroll bar appear. But when the list line too long, there is no horizontal scroll bar. How to add the Horizontal scroll bar when line exceeded windows size?:confused:
Printable View
When there are more items in the list box, the vertical scroll bar appear. But when the list line too long, there is no horizontal scroll bar. How to add the Horizontal scroll bar when line exceeded windows size?:confused:
vb Code:
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Public Const LB_SETHORIZONTALEXTENT = &H194 Public Function ListBoxHBar(LstBox As ListBox, Frm As Form) Dim lngReturn As Long Dim lngExtent As Long With Frm .ScaleMode = 3 .Font = LstBox.Font .FontBold = LstBox.FontBold .FontItalic = LstBox.FontItalic .FontSize = LstBox.FontSize For i = 0 To LstBox.ListCount - 1 If lngExtent < .TextWidth(LstBox.List(i)) Then lngExtent = .TextWidth(LstBox.List(i)) Next i End With lngReturn = SendMessage(LstBox.hWnd, LB_SETHORIZONTALEXTENT, lngExtent, 0&) End Function
Code found here
Or, you can try thisvb Code:
Private Declare Function ShowScrollBar Lib "user32" _ (ByVal hwnd As Long, ByVal wBar As Long, _ ByVal bShow As Long) As Long Private Const SB_HORIZONTAL = 0 Private Sub Form_Load() ShowScrollBar List1.hwnd, SB_HORIZONTAL, True End Sub
Thanks everyone, solved.:)