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.
User avatar
angelofstealth
Posts: 67
Joined: Wed Feb 13, 2013 4:26 pm

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

Post by angelofstealth » Fri Mar 08, 2019 2:50 pm

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

User avatar
jvierra
Posts: 13793
Joined: Tue May 22, 2007 9:57 am
Contact:

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

Post by jvierra » Fri Mar 08, 2019 3:15 pm

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: 67
Joined: Wed Feb 13, 2013 4:26 pm

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

Post by angelofstealth » Mon Mar 11, 2019 12:01 pm

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 19 times

User avatar
jvierra
Posts: 13793
Joined: Tue May 22, 2007 9:57 am
Contact:

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

Post by jvierra » Mon Mar 11, 2019 12:23 pm

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: 67
Joined: Wed Feb 13, 2013 4:26 pm

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

Post by angelofstealth » Mon Mar 11, 2019 12:29 pm

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: 67
Joined: Wed Feb 13, 2013 4:26 pm

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

Post by angelofstealth » Mon Mar 11, 2019 1:05 pm

I see it now, i am pre-creating it in the Add-Node function.

User avatar
jvierra
Posts: 13793
Joined: Tue May 22, 2007 9:57 am
Contact:

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

Post by jvierra » Mon Mar 11, 2019 1:38 pm

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: 67
Joined: Wed Feb 13, 2013 4:26 pm

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

Post by angelofstealth » Mon Mar 11, 2019 6:01 pm

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.

User avatar
jvierra
Posts: 13793
Joined: Tue May 22, 2007 9:57 am
Contact:

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

Post by jvierra » Mon Mar 11, 2019 6:45 pm

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.

Locked