Results 1 to 4 of 4

Thread: Listbox horizontal scroll bar

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2007
    Posts
    48

    Listbox horizontal scroll bar

    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?

  2. #2
    Lively Member
    Join Date
    Nov 2007
    Location
    Rochester, NY
    Posts
    111

    Re: Listbox horizontal scroll bar

    vb Code:
    1. 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
    2. Public Const LB_SETHORIZONTALEXTENT = &H194
    3.  
    4. Public Function ListBoxHBar(LstBox As ListBox, Frm As Form)
    5. Dim lngReturn As Long
    6. Dim lngExtent As Long
    7. With Frm
    8. .ScaleMode = 3
    9. .Font = LstBox.Font
    10. .FontBold = LstBox.FontBold
    11. .FontItalic = LstBox.FontItalic
    12. .FontSize = LstBox.FontSize
    13. For i = 0 To LstBox.ListCount - 1
    14. If lngExtent < .TextWidth(LstBox.List(i)) Then lngExtent = .TextWidth(LstBox.List(i))
    15. Next i
    16. End With
    17. lngReturn = SendMessage(LstBox.hWnd, LB_SETHORIZONTALEXTENT, lngExtent, 0&)
    18. End Function

    Code found here

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Listbox horizontal scroll bar

    Or, you can try this
    vb Code:
    1. Private Declare Function ShowScrollBar Lib "user32" _
    2. (ByVal hwnd As Long, ByVal wBar As Long, _
    3. ByVal bShow As Long) As Long
    4.  
    5. Private Const SB_HORIZONTAL = 0
    6.  
    7. Private Sub Form_Load()
    8. ShowScrollBar List1.hwnd, SB_HORIZONTAL, True
    9. End Sub

  4. #4

    Thread Starter
    Member
    Join Date
    Nov 2007
    Posts
    48

    Re: Listbox horizontal scroll bar

    Thanks everyone, solved.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width