Listbox without ScrollBar

D

DS

Can I make a listbox without a scrollbar?
Can I make two command buttons one to scroll up the other to scroll down
instead of the scroll bar?
Thanks
DS
 
S

Stephen Lebans

There is code here demonstrating how to programmatically scroll through a
ListBox.
http://www.lebans.com/List_Combo.htm#ArrowKeysListBox

You could place the code below behind a pair of CommandButton controls.:

If you'd like to use the Arrow Keys to navigate through a ListBox even if
the ListBox does not have the focus then read on.



Go to Form properties and set the Key Preview to Yes.

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

Select Case KeyCode

Case vbKeyDown
Me.List2 = Me.List2.ItemData(Me.List2.ListIndex + 1)
KeyCode = 0


Case vbKeyUp
Me.List2 = Me.List2.ItemData(Me.List2.ListIndex - 1)
KeyCode = 0

Case Else
End Select

End Sub

Tthe above code is for a ListBox named List2. Change the name to reflect
your ListBox. Also this is set to work with a ListBox WITHOUT Column Headers
turned on. You'll have to adjust it if you use Column Headers. Finally the
Arrow Keys are sent to oblivion with the Line KeyCode =0.

Your mileage may vary. :)



--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top