-
Dec 26th, 2014, 07:05 PM
#1
Thread Starter
Fanatic Member
ListBox Vertical Scroll
IN VB6 I am populating a listbox via code. Vertical scroll bar appears after the box is filled. How do I, in code, keep the bottom entry, the last entry in view at the bottom of the lisbox. Now I have to manually scroll down.
Thanks
-
Dec 26th, 2014, 07:14 PM
#2
Re: ListBox Vertical Scroll
When needed: List1.ListIndex = List1.ListCount-1
-
Dec 26th, 2014, 08:07 PM
#3
Re: ListBox Vertical Scroll
Originally Posted by AccessShell
How do I, in code, keep the bottom entry, the last entry in view at the bottom of the lisbox.
Until you have added 1 item more than what can be viewed in the view area the last item added will not appear at the bottom because the vertical scrollbar is not yet visible so each item is displayed one under the previous then once you add the the item that exceeds the view area the last item entered will be visible at the bottom of the listbox by keeping the scrollbar at the bottom using the line LaVolpe posted
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Dec 26th, 2014, 09:21 PM
#4
Re: ListBox Vertical Scroll
If you prefer not to select the newest item while populating the ListBox (and therefore avoid code in the ListBox's Click event from firing prematurely), the following alternate way achieves the same effect:
Code:
List1.TopIndex = List1.NewIndex
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
-
Dec 26th, 2014, 09:44 PM
#5
Thread Starter
Fanatic Member
Re: ListBox Vertical Scroll
Originally Posted by Bonnie West
If you prefer not to select the newest item while populating the ListBox (and therefore avoid code in the ListBox's Click event from firing prematurely), the following alternate way achieves the same effect:
Code:
List1.TopIndex = List1.NewIndex
Thanks. This works like a charm!
-
Dec 26th, 2014, 10:02 PM
#6
Re: ListBox Vertical Scroll
Don't forget to mark this thread Resolved!
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|