Vscrollbar in Treeview

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 4 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
daniel kusnir
Posts: 75
Last visit: Tue May 23, 2023 10:50 am
Answers: 1

Vscrollbar in Treeview

Post by daniel kusnir »

Hello

does anybody know how custom Vscroll can be used for scrolling down the Treeview full of nodes and childnodes ? i can use it only when i have a nodes, but unfortunatelly it does not work when childnodes are there.
my simple code :
  1. $vscrollbar1_Scroll = [System.Windows.Forms.ScrollEventHandler]{
  2.    
  3.     $treeview1.TopNode = $treeview1.Nodes[$vscrollbar1.Value]
  4.    
  5. }
thanks
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Vscrollbar in Treeview

Post by jvierra »

Why? The TreeView has its own scrollbars. They will turn on when needed. To be sure the children are expanded use the "ExpandAll" method of the tree control.

$treeview1.ExpandAll()
User avatar
daniel kusnir
Posts: 75
Last visit: Tue May 23, 2023 10:50 am
Answers: 1

Re: Vscrollbar in Treeview

Post by daniel kusnir »

because i have 2 treeviews and want to create 1 VSBar to scroll them both. similar to text comparators, i need to build treeview comparator
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Vscrollbar in Treeview

Post by jvierra »

Ok. Just send scroll commands to both TreeView controls. You can send scroll commands by scroll position and the two will track with the control.
User avatar
daniel kusnir
Posts: 75
Last visit: Tue May 23, 2023 10:50 am
Answers: 1

Re: Vscrollbar in Treeview

Post by daniel kusnir »

to be honest, i have been trying to implement this approach as well, but without luck - it seems even more complicated. Can you give me some example or some working code ?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Vscrollbar in Treeview

Post by jvierra »

Sorry - I don't have any samples.
User avatar
daniel kusnir
Posts: 75
Last visit: Tue May 23, 2023 10:50 am
Answers: 1

Re: Vscrollbar in Treeview

Post by daniel kusnir »

figured it out. what you suggested is very complicated. turns out solution is super simple

1. create an array and assign custom index to each value
2. compare scroll value to custom index value
3. set selectednode to node that contains this custom index
4. create afterselect event and set topnode as selected node
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Vscrollbar in Treeview

Post by jvierra »

Oh. I thought you were asking how to synchronize the scroll bars. You are just trying to select the nodes.

To select nodes you don't need an array. Just select the nodes as they occur in the tree by getting the direction of scroll.
User avatar
daniel kusnir
Posts: 75
Last visit: Tue May 23, 2023 10:50 am
Answers: 1

Re: Vscrollbar in Treeview

Post by daniel kusnir »

that is correct - i needed to sync the scrollbars. And this is only solution i came up in order not to do any heavy coding.
As i do not know how to scroll to child, i simply select that child that has same index as vscrollbar and make it appear on top.But no matter the path, result works 100 % percent. Too bad i cannot simply attach the solution
gugyhodge
Posts: 1
Last visit: Thu Jan 23, 2020 12:42 am

Re: Vscrollbar in Treeview

Post by gugyhodge »

I did not like the gray style of their ScrollBars vertical and horizontal. Is it possible to change it somehow, I want gradient ScrollBars. How can I do that and how to learn precalculus fast?
This topic is 4 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked