is it possible to add a horizontal scroll bar to my listbox, because sometimes the items in it get quite lengthly.
Printable View
is it possible to add a horizontal scroll bar to my listbox, because sometimes the items in it get quite lengthly.
No friend, i don't think so it is possible to add a horizontal scroll bar to a list box.
:p kinjal :p
Go to http://www.mvps.org/vbnet/ and do a search for "listbox horizontal" and you'll find your answer.
In case you haven't found it, here's the code. (To run this example, put a listbox with the default name List1 on your form, then paste this code into the form.)
Code:Option Explicit
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
Private Const LB_SETHORIZONTALEXTENT = &H194
Private Sub Form_Load()
List1.AddItem "Line 1"
List1.AddItem "a big Line 2 some text some text"
List1.AddItem "line 2"
List1.AddItem "Line 3"
addHorScrlBarListBox List1
End Sub
Public Sub addHorScrlBarListBox(ByVal refControlListBox As Object)
Dim nRet As Long
Dim nNewWidth As Integer
nNewWidth = 400 ' new width in pixels
nRet = SendMessage(refControlListBox.hwnd, _
LB_SETHORIZONTALEXTENT, nNewWidth, ByVal 0&)
End Sub