Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listbox with Vscrollbar and Hscrollbar at the same time ???? 2

Status
Not open for further replies.

Dydom

Programmer
Apr 30, 2002
10
FR
Hi,
I want to use a listbox with a vertical scroll and a horisontal scroll, but in the property, we can use only one or the other, so I need an alternate choice !
If anyone can help me ...
Thanks
Dom
 
try to use a combo box and set the width in design. The vertical scroll bar should auto show as you have the combo1.additem "Item".
I use it all of the time.
 
Something like the following should work:
[tt]
Option Explicit
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Const LB_SETHORIZONTALEXTENT = &H194

Private Sub AddAndModifyHScroll(lst As ListBox)
' depends on the scalewidth
' if scalemode is Twips then Divide MaxWidth by TwipsPerPixel to get pixels
Dim lp As Long
Dim MaxWidth As Long

For a = 0 To lst.ListCount - 1
If Me.TextWidth(lst.List(a)) > MaxWidth Then MaxWidth = Me.TextWidth(lst.List(a))
Next

SendMessage lst.hwnd, LB_SETHORIZONTALEXTENT, MaxWidth / Screen.TwipsPerPixelX, 0
End Sub
 
Thanks to everyone,
Finally, I use the Strongm solution which work perfectly after trying with richtextbox and msflexgrid without success.
Thanks for your help
Dom
 
Because I need to use the column function of the listbox, I need to make a V Scroll, because the HScroll is automatically made by the listbox when the columns property was not 0 so, if Strongm have an alternate choice to do it ... And I have some pb to use the columns property!
In fact, I want to use it like this :
list2.columns list1.listcount-1
I have tried with Set ... but that don't work, why ?
Thanks for your help
Dom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top