dcsimg
Results 1 to 2 of 2

Thread: Programmatically page treeview content forward and backwards in display window

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2017
    Posts
    3

    Programmatically page treeview content forward and backwards in display window

    I have a treeview populated with a very large number of nodes. Only a small percentage of it is visible in the default sized window and it's clumsy scrolling it forward and backwards using the vertical scrollbar. I'd like to have two buttons to page the displayed treeview content forward and backwards in the visible (user sizeable) window. Anyone have a sample of how to do this?

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    100,058

    Re: Programmatically page treeview content forward and backwards in display window

    There's no magic to it. Unlike some other controls, the TreeView doesn't have a virtual mode. You presumably already know how to load nodes into a TreeView so you just have to do that each time the user clicks one of your Buttons. It's up to you to determine how to keep track of the overall data and where you currently are within it. There isn't one right way to do it and the best way would depend on the data and its source.

    One thing I would suggest is that, when you navigate away from a page, you don't discard the nodes it contains. Keep those nodes in memory even if you don't keep them in the controls, so you can reload them later if the user navigates back again.

    Also, you would need to decide whether to wait until a page is required to load it or to load data in the background so that it's ready to load immediately that the user wants it. You might even do something in between, e.g. load the next five pages from where you currently are so that they are ready to load immediately into the control. If the user navigates to the next page, you load another page so that you still have five in the bag.

    Again, there's no one right way to do it. You should do some planning first, i.e. decide how you want it to work. Only once you have it planned should you think about writing code to implement that plan. Writing code is always easier if you actually know what it has to do beforehand. If and when you encounter an actual issue, then you can ask us about that specifically. That's a far better way to learn than having others provide code to copy and paste. It can feel like you're learning in that case because you think that you just learned what that code does but if you can't reproduce the thought processes to produce that code then you've actually learned little to nothing.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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
  •  



Featured


Click Here to Expand Forum to Full Width