Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Auto-scroll ListView

Auto-scroll ListView

Scheduled Pinned Locked Moved Visual Basic
tutorialquestion
9 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • X Offline
    X Offline
    xshi005
    wrote on last edited by
    #1

    Hi there, Is there anyone know how to make a windows form listview control always automatically scroll to the last item when loading lots of items into the list? Thanks a lot. Frank

    P K 2 Replies Last reply
    0
    • X xshi005

      Hi there, Is there anyone know how to make a windows form listview control always automatically scroll to the last item when loading lots of items into the list? Thanks a lot. Frank

      P Offline
      P Offline
      Pablo ar
      wrote on last edited by
      #2

      Try this, right after populating the list view: lvMyListOfItems.ListItems(lvMyListOfItems.ListItems.Count).Selected = True that's it! Cheers, Pablo.ar

      X 1 Reply Last reply
      0
      • X xshi005

        Hi there, Is there anyone know how to make a windows form listview control always automatically scroll to the last item when loading lots of items into the list? Thanks a lot. Frank

        K Offline
        K Offline
        kostasvel
        wrote on last edited by
        #3

        Me.ListView1.EnsureVisible(Me.ListView1.Items.Count - 1)

        X 1 Reply Last reply
        0
        • P Pablo ar

          Try this, right after populating the list view: lvMyListOfItems.ListItems(lvMyListOfItems.ListItems.Count).Selected = True that's it! Cheers, Pablo.ar

          X Offline
          X Offline
          xshi005
          wrote on last edited by
          #4

          Thanks, Pablo.ar. But it does not work, because what I need it is to always show the last item while the items are loading. Frank

          P 1 Reply Last reply
          0
          • K kostasvel

            Me.ListView1.EnsureVisible(Me.ListView1.Items.Count - 1)

            X Offline
            X Offline
            xshi005
            wrote on last edited by
            #5

            Thanks a lot, kostasV. That is really what I need. Frank

            1 Reply Last reply
            0
            • X xshi005

              Thanks, Pablo.ar. But it does not work, because what I need it is to always show the last item while the items are loading. Frank

              P Offline
              P Offline
              Pablo ar
              wrote on last edited by
              #6

              Just put that line right at the end (still, inside!) of the loop block: Do ...your block of code ...your block of code ...your block of code lvMyListOfItems.ListItems(lvMyListOfItems.ListItems.Count).Selected = True Loop So, right before the loop loops, it will select (and scroll to) the last item. ;) Pablo.ar

              X 1 Reply Last reply
              0
              • P Pablo ar

                Just put that line right at the end (still, inside!) of the loop block: Do ...your block of code ...your block of code ...your block of code lvMyListOfItems.ListItems(lvMyListOfItems.ListItems.Count).Selected = True Loop So, right before the loop loops, it will select (and scroll to) the last item. ;) Pablo.ar

                X Offline
                X Offline
                xshi005
                wrote on last edited by
                #7

                Hi Pablo Thanks for your reply. But I think you might be talking about some list control other than MS ListView, since ListView does not have ListItems property (while it does have Items property). And your statement can be: lvMyListOfItems.Items(lvMyListOfItems.Items.Count - 1).Selected = True This statement will select all the items after the loop completes. However, it can not auto-scroll the listview while loading items. It is another stupid MS control, since many other third-party controls can do it without any code. Meanwhile, kostasV provides a solution that meets my need. Thanks again for your time. Frank

                P 1 Reply Last reply
                0
                • X xshi005

                  Hi Pablo Thanks for your reply. But I think you might be talking about some list control other than MS ListView, since ListView does not have ListItems property (while it does have Items property). And your statement can be: lvMyListOfItems.Items(lvMyListOfItems.Items.Count - 1).Selected = True This statement will select all the items after the loop completes. However, it can not auto-scroll the listview while loading items. It is another stupid MS control, since many other third-party controls can do it without any code. Meanwhile, kostasV provides a solution that meets my need. Thanks again for your time. Frank

                  P Offline
                  P Offline
                  Pablo ar
                  wrote on last edited by
                  #8

                  If you still want to give a try to the way I showed you, make sure you set the listview property 'Multiselect' to false. I think that's why the code I gave you didn't work, anyhow, you did get the solution in a better way. 1st class code there, kostasV! Pablo.ar

                  X 1 Reply Last reply
                  0
                  • P Pablo ar

                    If you still want to give a try to the way I showed you, make sure you set the listview property 'Multiselect' to false. I think that's why the code I gave you didn't work, anyhow, you did get the solution in a better way. 1st class code there, kostasV! Pablo.ar

                    X Offline
                    X Offline
                    xshi005
                    wrote on last edited by
                    #9

                    Thank you, Pablo.ar. Frank

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups