LISTBOX QUESTION 
Author Message
 LISTBOX QUESTION

Hi All,
How do I force a horizontal scrollbar in the listbox control ?

TIA
Guy Cohen



Sun, 14 Jan 2001 03:00:00 GMT  
 LISTBOX QUESTION
Check out Randy's VBNet site (http://www.mvps.org/vbnet/), there's code
there that will do just this.

Regards

Chris Eastwood
Software Engineer
ACNielsen Ltd

Quote:

>Hi All,
>How do I force a horizontal scrollbar in the listbox control ?

>TIA
>Guy Cohen



Sun, 14 Jan 2001 03:00:00 GMT  
 LISTBOX QUESTION
Hi , I searched there and could not find any... Please help!
Guy Cohen


Sun, 14 Jan 2001 03:00:00 GMT  
 LISTBOX QUESTION
Here You Go. This is what i use.

Private Const LB_SETHORIZONTALEXTENT = &H194
Private 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 Sub SetHorizontalScroll(CurrForm As Form, Cntrl As Listbox,
LongestListText As String)
   Dim SavedScaleMode As Integer
   Dim TextWidthPixels As Integer

   If trim$(LongestListText) = "" Then
      Exit Sub
   End If

   SavedScaleMode = CurrForm.ScaleMode
   CurrForm.ScaleMode = vbPixels
   TextWidthPixels = CurrForm.TextWidth(trim$(LongestListText))
   TextWidthPixels = TextWidthPixels + ((TextWidthPixels / 10) * 2)
   SendMessage Cntrl.hWnd, LB_SETHORIZONTALEXTENT, TextWidthPixels, 0
   CurrForm.ScaleMode = SavedScaleMode
End Sub

USAGE:
    You need to supply the largest string that is in the List box so the
Routine can calculate the Max for the scroll bar. So just just save the
longest string or set to a larger constant.

    List1.Clear
    List1.Additem "String1"
    List1.Additem "String12345"
    List1.Additem "String12"
    List1.Additem "String123"
    List1.Additem "String1234"

    SetHorizontalScroll me,  list1, "String12345"



Sun, 14 Jan 2001 03:00:00 GMT  
 LISTBOX QUESTION
On Wed, 29 Jul 1998 16:43:38 +0300, "Guy Cohen"

Quote:

>Hi All,
>How do I force a horizontal scrollbar in the listbox control ?

>TIA
>Guy Cohen

        Don't you just set columns in Property list to 1?


Mon, 15 Jan 2001 03:00:00 GMT  
 LISTBOX QUESTION
Here's some code Randy posted ages ago - you'll have to play around with the
hSize Parameter to get it to work in your app.

Const LB_SETHORIZONTALEXTENT = &H194

Dim hSize as Long
'

hSize = 350

Call SendMessage(List1.hwnd, LB_SETHORIZONTALEXTENT, hSize, ByVal 0&)

HTH

Chris Eastwood
Software Engineer
ACNielsen Ltd

Quote:

>Hi , I searched there and could not find any... Please help!
>Guy Cohen



Tue, 16 Jan 2001 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. ListBox question

2. ListBox question

3. ListBox Question

4. Listbox question

5. Databinding & ListBox question

6. Listbox question

7. Listbox Question...

8. ComboBox / ListBox Question...

9. Newbie: Update ListBox Question

10. Newbie ListBox Question

11. Combobox and listbox questions

12. Listbox question?

 

 
Powered by phpBB® Forum Software