How to prevent the option ?

Андрей Михалевский 2,386 Reputation points

Hello. I want to make a menu. For example:

Add-Type -AssemblyName System.Windows.Forms  
$form = New-Object System.Windows.Forms.Form  
$form.Text = 'Data Entry Form'  
$form.Size = New-Object System.Drawing.Size(300,200)  
$form.StartPosition = 'CenterScreen'  
$form.Topmost = $true  

When I close a menu, I always see "Cancel" in the console

Where does it come from and how to prevent it? When converting to exe, when I close the program, I also get an additional window with the text 'Cancel'


Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,174 questions
0 comments No comments
{count} votes

Accepted answer
  1. Rich Matheisen 42,906 Reputation points

    You're using "ShowDialog" with no options. That produces a modal dialog box. That means you need a way to dismiss the dialog box. Without the "Cancel" (which is the name of the button you used to close the dialog box) you have no way to know why the dialog box was closed and what action to take (if there were multiple choices offered to the user).

    I think you probably wanted to use the "Show" method and not "ShowDialog".

    0 comments No comments

0 additional answers

Sort by: Most helpful