Dynamically build cascading menu from directory structure

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.
Locked
User avatar
PGomersall
Posts: 106
Last visit: Fri Apr 16, 2021 7:00 pm

Dynamically build cascading menu from directory structure

Post by PGomersall »

Hi at Sapien,
Have you any examples of dynamically building a cascading toolstripmenu from a simple directory tree (2\3 levels deep) and adding files within the tree as items with click events? Obviously given a set starting root folder.
I am trying to add this kind of structure to a system tray app.
Pete

jvierra
Posts: 14790
Last visit: Fri May 14, 2021 3:47 pm
Answers: 9
Has voted: 3 times
Been upvoted: 9 times

Re: Dynamically build cascading menu from directory structure

Post by jvierra »

For this kind of structure we would use a TreeView control. Doing this complex of a structure from a tray app would be disruptive. Just have the tray app open a dialog with a TreeView control.

Locked