Product: PowerShell Studio 2022 (64 Bit)
Build: v5.8.199
OS: Windows 10 Pro (64 Bit)
Build: v10.0.19043.0
Hello,
I have a contextmenu with a submenu which is filled dynamically by a xml-file. How can I add a click event for a dynamic build submenu?
The parent entry "Lang" is created in with the designer.
contextmenu submenu click
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.
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.
Re: contextmenu submenu click
The following article will tell you how to use a context menu.
https://info.sapien.com/index.php/guis/ ... ip-control
https://info.sapien.com/index.php/guis/ ... ip-control
Re: contextmenu submenu click
yes, i know this article and read it.jvierra wrote: ↑Sat Jan 22, 2022 12:06 pm The following article will tell you how to use a context menu.
https://info.sapien.com/index.php/guis/ ... ip-control
I tried the example from this, it's only applied to the main entry "Lang".
But I have no idea how to add an event for the submenu. What do I miss here or I don't understand all of this.
I using contextmenu in other forms too, but here I created it completly with the designer and had no problems
Re: contextmenu submenu click
The article explains that in detail. It also has a cod example. You will have to carefully follow the article and it is normal to copy the steps in a form and try each element until you understand how the control works.
Here is an excellent free beginner's book that covers basic PowerShell with a small amount of info on how to use PowerShell with WinForms.
https://www.sapien.com/books_training/W ... werShell-4
It is critical to learn how to read technical documentation when working with high technology systems like computers. If you are just an end user then you can get away with some guess work but to write code, then learning the technology from the documentation is required although there are classes that can be taken that will get you started.Important Events:
ItemClicked
This event occurs when a menu item is clicked. Use this event as a general catch all event for the menu items. It allows you to react to the menu item clicks without having to set each individual menu item’s click event.
You can access the clicked item by accessing the event’s argument ClickItem property:
$_.ClickedItem
Here is an excellent free beginner's book that covers basic PowerShell with a small amount of info on how to use PowerShell with WinForms.
https://www.sapien.com/books_training/W ... werShell-4
Re: contextmenu submenu click
In the link you'll find the following which addresses your issue I believe:paddy75 wrote: ↑Sat Jan 22, 2022 1:21 pmyes, i know this article and read it.jvierra wrote: ↑Sat Jan 22, 2022 12:06 pm The following article will tell you how to use a context menu.
https://info.sapien.com/index.php/guis/ ... ip-control
I tried the example from this, it's only applied to the main entry "Lang".
But I have no idea how to add an event for the submenu. What do I miss here or I don't understand all of this.
I using contextmenu in other forms too, but here I created it completly with the designer and had no problems
"This event occurs when a menu item is clicked. Use this event as a general catch all event for the menu items. It allows you to react to the menu item clicks without having to set each individual menu item’s click event.
You can access the clicked item by accessing the event’s argument ClickItem property:
$_.ClickedItem"