Treeview - Node - Property (Plus/Minus)

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 5 years and 2 weeks 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
angelofstealth
Posts: 69
Last visit: Wed Sep 28, 2022 10:04 am

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

Post by angelofstealth »

Understand, appreciate explaining/attaching the link.

I like this method of loading the nodes as it is fast and doesn't hang the GUI. Reading/referencing the following link below with Dan potter example the GUI will hang if the OU has a lot of objects (organization units / containers ). I like the clean look of the GUI/object select so forth.

viewtopic.php?t=10784

Thanks jvierra
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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

Post by jvierra »

The ADSI load does not take advantage of mechanism to load very large children. This can be managed by controlling what is in view. ADSI can be written to retrieve some of the objects and continue incrementally. These methods can be use to keep the tree alive.

We can also load nodes as jobs and return the loaded node and just attach it to the tree when available.
User avatar
angelofstealth
Posts: 69
Last visit: Wed Sep 28, 2022 10:04 am

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

Post by angelofstealth »

Looks like I got most of it working with a job, only issue seems when loading the treeview. When I click the node it loads the default imageindex[0] with a blank name. I clear this if the objects returns are zero from the job. Wondering if there is a way to stop the treeview from display the progress dropdown prior to updating the treeview. Code attached, thanks
Attachments
adtree - job.psf
(31.06 KiB) Downloaded 111 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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

Post by jvierra »

Not sure what the issue is. You need to start with a root node. The filler assumes a root and stars from there.

I also see no need for using a job. It completely defeats the point of my example.
User avatar
angelofstealth
Posts: 69
Last visit: Wed Sep 28, 2022 10:04 am

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

Post by angelofstealth »

The point of using the job is so the GUI does not freeze(not responding) during a lookup that is taking a long time to return due to too many objects being returned.

In regards to the issue, if you comment out the clear in the else statement in CompletedScript you will see the default object get created. Not a big issue at all, was just curious if had to be created when clicked.
User avatar
angelofstealth
Posts: 69
Last visit: Wed Sep 28, 2022 10:04 am

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

Post by angelofstealth »

I see it now, i am pre-creating it in the Add-Node function.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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

Post by jvierra »

The GUI will not freeze with my example. It only loads a node when the nose is clicked. No waiting. We load only the containers when a node is clicked. Even it you have 100 OUs the load is almost instantaneous,
User avatar
angelofstealth
Posts: 69
Last visit: Wed Sep 28, 2022 10:04 am

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

Post by angelofstealth »

I agree, I have tested with your example and it does not freeze the GUI. But it does not give any indication of nodes having nodes/childnodes under them. The only way you can know is by clicking on the OU/childnode. When you have a very large Active Directory environment with cascading OU's that becomes a real pain. Just to give an example, we have one OU that has over 1600 OU's/childnodes below it. Trying to make it look/feel like how it looks in Active Directory Users and Computers.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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

Post by jvierra »

That is how it works or you have to load the whole thing at once. If you do that then the form will freeze.

This won't happen in a compiled program because we can use threading or tasks to load in the background. Loading a hierarchy with PowerShell cannot be done with multiple threads and jobs are not threads.

PowerShell cannot be used to create classic Windows applications. That is the limitation. You can synthesize some app behavior but PS is not designed or intended to be an applications development language. It is a management automation shell language. We can do many things to extend this but all require extensive programming skills and Windows programming experience.
This topic is 5 years and 2 weeks 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