How to show only + on OU's with children

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 1 year and 4 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
PGomersall
Posts: 131
Last visit: Thu Feb 15, 2024 12:14 pm

How to show only + on OU's with children

Post by PGomersall »

Hi,
I have been using the attached example psf treeview control that originally came for this forum to display an AD forest. I really like how quick it renders compared to other examples I have found.
However, one thing I would like to improve, but have not worked out how to do this, is to only show + signs for OU's that have children. Is there any way to make this example do this?
Any help on doing this would be greatly appreciated.
Pete
Attachments
AD-Tree.psf
(22.48 KiB) Downloaded 40 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: How to show only + on OU's with children

Post by jvierra »

That is how it works normally. No children --- no plus sign.
User avatar
PGomersall
Posts: 131
Last visit: Thu Feb 15, 2024 12:14 pm

Re: How to show only + on OU's with children

Post by PGomersall »

Yes jvierra that is what I want, but the psf I attached in the initial post does not do that; it has a + on all OU's including those without children.
What I need is how to make it work like you say it should. In the below image the AD-Tree form is the one I am using but as you see there are a + on every OU. The other example is another OU adtree psf that is also on your site here, it works much slower but it does show the correct + on the OU's and not on those with no children.
I wonder if you could take a look at the AD-Tree.psf I attached on a domain and try and see what the issue is? I am sure it is to do with how the nodes are added but I am not sure how to fix it.
AD-TreeView.png
AD-TreeView.png (89.97 KiB) Viewed 926 times
Regards,
Pete
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: How to show only + on OU's with children

Post by jvierra »

If there are sub nodes it will show a plus and a minus when the node is expanded.

Here is proof:
tree.png
tree.png (25.99 KiB) Viewed 923 times
User avatar
PGomersall
Posts: 131
Last visit: Thu Feb 15, 2024 12:14 pm

Re: How to show only + on OU's with children

Post by PGomersall »

jvierra ,
I am sorry but we are misunderstanding each other.
I see your image and I see how it is supposed to work. That image is like the right side of the image in my last post - how it should work.
If you look at the left side of my image - this is clearly not working like the right side.
Take a look at the OU Builtin in the left image - it has no child OU but it shows a plus.
If I click that OU it does "expand" and the + disappears, is that because the code is not trying to enumerate the branch until it is clicked, and that is the reason it it much faster?
The left side was created using the originally attached psf. I was hoping that we could work to find what was broken in it if opening and running it on a domain joined computer to see what it renders in the treeview.
Pete
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: How to show only + on OU's with children

Post by jvierra »

It is not broken. That is how the TreeView works. There is no way to change that behavior. You would have to biuld a custom control or manually do all of the painting to change that behavior.
This topic is 1 year and 4 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