Code example for controls

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 7 years and 3 months 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
dveenstra
Posts: 10
Last visit: Tue Oct 19, 2021 6:02 am

Code example for controls

Post by dveenstra »

Product, version and build: PowerShell Studio 2016 5.3.130
32 or 64 bit version of product: 64 bits
Operating system: Windows 7
32 or 64 bit OS: 64 bits
PowerShell Version: 4.0

Hi everyone,

I'm new to PowerShell studio, there are lots of controls that can be used to build GUI form. However I'm struggling to find code examples for some of these controls.
Example:

I cannot find enough example for Menu strip or Menu button, of how I can populate the menu, and how click event can be triggered when you click on individual menu item.
Can someone please point me to the right direction.

Thanks!
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Code example for controls

Post by davidc »

For help on how to use GUI controls, please refer to our info.sapien.com page:

http://info.sapien.com/index.php/guis

In PowerShell Studio, you can to go Ribbon->Help Tab->Product Support->Samples and it will take you to some sample contain in the SAPIEN Document Explorer. We are currently in the process of creating a new batch of GUI samples and we hope to release them sometime soon.

You can access Microsoft's MSDN help website directly from the designer by right-clicking the control and navigating to the help menu from the designer content menu:
Designer - Help.png
Designer - Help.png (18.4 KiB) Viewed 1906 times
You can also access our Spotlight on Controls articles with the context menu.
David
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: Code example for controls

Post by jvierra »

When you add a menu you can add items. Just type in the name. TO access the click event double click the item in the designer and it will create the event for that item.

Be sure to review all of the items in David's post as it will save you time later and help you to approach a design more easily.
User avatar
dveenstra
Posts: 10
Last visit: Tue Oct 19, 2021 6:02 am

Re: Code example for controls

Post by dveenstra »

Thanks,
For the menu strip control
the http://info.sapien.com/index.php/guis link only shows ContextMenuStrip Control.
When I right click on menu strip, it does not bring up Help context menu...
There's no spot light article.

I've finally figured out how to use menu strip by looking at new form -> Menu template, with the help of WinForms Control Reference for PowerShell.
That the menu items are in the Items collection of the parent object. Thanks jvierra's comment.

For Menu Button control, if I add it and right click on it, all the help context are pointing to standard button... This appears to be a PowerShell studio specific customized control.

As for MSDN articles, I have been personally trying to avoid it as it's so dry to read, and lack of examples... I will only use it if I have exhausted all other resources. :)
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Code example for controls

Post by jvierra »

A MenuStrip does not have a button.
A MenuButton is a custom control set.

The top panel is a good place to search for help.

Use MSDN Help section for help with MenuStrip and other Microsoft controls that have no "Spotlight" article..
This topic is 7 years and 3 months 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