Page 1 of 2

Treeview - Node - Property (Plus/Minus)

Posted: Thu Mar 07, 2019 10:55 am
by angelofstealth
Is there a way to force or add a property to add the ShowPlusMinus to a treeview node? Example code below, works fine as far as loading in the objects in the treeview and clicking down through the treeview. Just none of my dropdowns will have Plus or Minus, the property is set by default to true and i have even code it on the treeview. No change. Treeview events are being loaded by NodeMouseClick to populate the treeview cascading, but without Plus Minus. I know I could detect for child items, just dont know how to force the property to have the plus/minus.
  1. $n = New-Object System.Windows.Forms.TreeNode
  2. $n.Name = $key
  3. $n.Text = $nodeName
  4. $n.ImageIndex = 0
  5. $n.SelectedImageIndex = 0
  6. $treeview.Nodes.Add($n)

Re: Treeview - Node - Property (Plus/Minus)

Posted: Thu Mar 07, 2019 11:52 am
by jvierra
The attached PSF will explain it all.

Re: Treeview - Node - Property (Plus/Minus)

Posted: Thu Mar 07, 2019 11:58 am
by jvierra

Re: Treeview - Node - Property (Plus/Minus)

Posted: Thu Mar 07, 2019 12:03 pm
by angelofstealth
Is there not a way to add the show plus/minus on adding the node vs on click? As with the psf attached my code is doing the same thing by showing the dropdown/plus after a click and not when the nodes are added.

Re: Treeview - Node - Property (Plus/Minus)

Posted: Thu Mar 07, 2019 12:28 pm
by angelofstealth
I think i am going to adjust the way i load in the values with the node mouse click. Appreciate the help , should be good from here.

Re: Treeview - Node - Property (Plus/Minus)

Posted: Thu Mar 07, 2019 12:46 pm
by jvierra
The plus/minus is added automatically if the property is set to true. The demo just shows how to turn it on and off.

Carefully read all of the link I posted.

Re: Treeview - Node - Property (Plus/Minus)

Posted: Thu Mar 07, 2019 12:56 pm
by angelofstealth
I agree it should be added automatically, i stated that in my first message.

In your attached psf, if I change the form property showplusminus from false (what is was) to true and run the code. It does not show a plus symbol on my end for C:\.

Re: Treeview - Node - Property (Plus/Minus)

Posted: Thu Mar 07, 2019 1:05 pm
by jvierra
Initially there are no child nodes under the root. After you click it there are and the p/m will show. The +- only shows whn there ae child nodes.

Please read the link carefully. All of the rules are spelled out.

Re: Treeview - Node - Property (Plus/Minus)

Posted: Thu Mar 07, 2019 1:23 pm
by angelofstealth
For the childnodes loaded after the click, these childnodes that have childnodes don't show having plus/minus. Only after clicking the childnodes will the next childnodes show is the point i am trying to make. Instead of clicking the parent node, load childnodes and display childnodes that have childnodes below them. Which is why i was looking for a property to set as I have no issues creating the treeview/nodes under eachother with other properties.

I will take a look at the link, just stating the psf provided is doing the same thing my code is doing which is not displaying childnodes (plus/minus) under childnodes after root/parent is clicked.

Re: Treeview - Node - Property (Plus/Minus)

Posted: Thu Mar 07, 2019 1:54 pm
by jvierra
Because the nodes are only loaded if you have clicked them. That is the behavior of an incremental load. The code was written to demonstrate an incremental load and not to demo the +-. Click on all nodes until all are loaded then use the +- and all loaded nodes with loaded children will behave as you want.