Custom message Box Help

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 6 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
mattys
Posts: 62
Last visit: Wed Dec 27, 2023 8:28 am
Has voted: 3 times

Custom message Box Help

Post by mattys »

I want to use a custom message box. When clicking 'Yes' in the message box form, an event is ran to open another child form in my project. My problem is the message box form stays open? No matter where I place the code to close a form, Im unable to close the message box form. My goal is to close the message box after the next form opens.
Any tips?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Custom message Box Help

Post by jvierra »

"ShowDialog" is an synchronous method. It executes and doesn't return until after the executed form clases.

There is no way around this. There are methods but then you would have to learn Winforms to a deeper level and then know more about Windows.

It is better that you return a result from your custom messagebox and test it after the call to display the message box then display the new form.
mattys
Posts: 62
Last visit: Wed Dec 27, 2023 8:28 am
Has voted: 3 times

Re: Custom message Box Help

Post by mattys »

Thank you for sharing your knowledge jvierra! I appreciate your time.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Custom message Box Help

Post by jvierra »

Sorry about the typos.
This topic is 2 years and 6 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