Vb6 Listbox scroll to last entry

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Wernerh
    New Member
    • Jul 2007
    • 104

    Vb6 Listbox scroll to last entry

    Hi, I have created a log in a listbox to show users everytime someone has logged on. Is there a form load function that will scroll down the listbox to the last entry each time the form is loaded??

    Thanks
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    Have you tried to set the listindex =listcount-1 ?

    Comment

    • Wernerh
      New Member
      • Jul 2007
      • 104

      #3
      Originally posted by debasisdas
      Have you tried to set the listindex =listcount-1 ?
      Hi just tried this code :

      List2.ListIndex = ListCount - 1

      No luck unfortunately

      Comment

      • debasisdas
        Recognized Expert Expert
        • Dec 2006
        • 8119

        #4
        Use this

        [code=vb]
        List1.ListIndex = List1.ListCount - 1
        [/code]

        Comment

        • Wernerh
          New Member
          • Jul 2007
          • 104

          #5
          Originally posted by debasisdas
          Use this

          [code=vb]
          List1.ListIndex = List1.ListCount - 1
          [/code]
          Thank you so much for your help - it now works

          Comment

          • devonknows
            New Member
            • Nov 2006
            • 137

            #6
            Originally posted by debasisdas
            Use this

            [code=vb]
            List1.ListIndex = List1.ListCount - 1
            [/code]
            If i may, Just adding alittle error checking on that

            [code=vb]
            If List1.Listcount > 0 then List1.Listindex = List1.Listcount - 1
            [/code]

            Stop any errors being triggered on the unlikely event that the Listbox is cleared, or items are removed.

            Kind Regards
            Devon

            Comment

            Working...