Items in ThemeStripMenuItem

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 2 years and 1 week 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
localpct
Posts: 397
Last visit: Thu Oct 27, 2022 5:57 am

Items in ThemeStripMenuItem

Post by localpct »

To go along with the Set-ControlTheme from Sapien I created a MenuItem to go along with the naming convention

Dark, Light, Custom
Snag_3bf76dd.png
Snag_3bf76dd.png (4.35 KiB) Viewed 1485 times

When I select a new theme, how do I uncheck the others?
Snag_3bfe016.png
Snag_3bfe016.png (4.26 KiB) Viewed 1485 times
User avatar
brittneyr
Site Admin
Posts: 1654
Last visit: Thu Mar 28, 2024 6:54 am
Answers: 39
Been upvoted: 30 times

Re: Items in ThemeStripMenuItem

Post by brittneyr »

[Topic moved by moderator to PowerShell GUIs forum]
Brittney
SAPIEN Technologies, Inc.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Items in ThemeStripMenuItem

Post by jvierra »

In the event for each checkbox just reset the checkboxes you want unchecked if the current event tells you the item is now checked.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Items in ThemeStripMenuItem

Post by jvierra »

Here is a quick code example of how to handle menu items. Add this to each of the menu item's "click" event and it will always clear the corresponding items according to the array of items you wish to group.
  1. $mymenuitems_Click = {
  2.     if ($this.Checked){
  3.         @($submenu1, $submenu2, $submenu3) |
  4.              Where-Object{ $_.Name -ne $this.Name } |
  5.              ForEach-Object{$_.Checked = $false}
  6.        
  7.     }
  8. }
This topic is 2 years and 1 week 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