Results 1 to 6 of 6

Thread: ListBox Vertical Scroll

  1. #1

    Thread Starter
    Fanatic Member AccessShell's Avatar
    Join Date
    Oct 2013
    Posts
    794

    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

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: ListBox Vertical Scroll

    When needed: List1.ListIndex = List1.ListCount-1
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: ListBox Vertical Scroll

    Quote Originally Posted by AccessShell View Post
    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.

  4. #4
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    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)

  5. #5

    Thread Starter
    Fanatic Member AccessShell's Avatar
    Join Date
    Oct 2013
    Posts
    794

    Re: ListBox Vertical Scroll

    Quote Originally Posted by Bonnie West View Post
    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!

  6. #6
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    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
  •  



Click Here to Expand Forum to Full Width