?
Solved

Listbox Horizontal Scroll

Posted on 1998-11-04
3
Medium Priority
?
715 Views
Last Modified: 2013-12-26
How do you add a horizontal scroll bar to a list box ?
I have only one column but the text lenght for each row is actually longer the listbox width I defined. I could not found a horizontal scroll bar function.

Vertical Scroll bar appears when the row gets bigger than the lenght of the listbox, but I cannot do that for horizontal ??

Thanks

Edith
0
Comment
Question by:Edithf
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 13

Accepted Solution

by:
Mirkwood earned 320 total points
ID: 1488121
Const LB_SETHORIZONTALEXTENT = &H194
Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
     (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
     lParam As Any) As Long

Dim x As Long
x = SendMessage(list1.hWnd, LB_SETHORIZONTALEXTENT, list1.Width * 2, _
     ByVal 0&)

Note: the `list1.Width*2' parameter specifies the scrollable width of the
listbox in pixels. You may need to adjust the form's ScaleMode or
otherwise experiment to find the best value.
0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1488122
Here is also a function for automatic adjustment. Call this function whenever the listbox is changed.

Declare Function SendMessage Lib "user32" Alias
"SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long,
ByVal wParam As Long, lParam As Long) As Long

Const WM_USER = &H400
Const LB_SETHORIZONTALEXTENT = WM_USER + 21

Sub CheckListBox
    Dim i%, res&
    Dim Scrollwidth&
   
    For i% = 0 To Form1.List1.ListCount
       If Form1.TextWidth(Form1.List1.List(i%)) > Scrollwidth& Then _
        Scrollwidth& = Form1.TextWidth(Form1.List1.List(i%))
    Next i%

    res& = SendMessage(Form1.List1.hWnd, LB_SETHORIZONTALEXTENT, _
        Scrollwidth&, 0&)
End Sub

0
 
LVL 1

Author Comment

by:Edithf
ID: 1488123
Thanks it works well now ....... I always have problem looking up for the function in the Library. Does the library function include in the C++ help ?
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question