Is it possible to put another value than yes no on a message box (system.windows.messagebox) ? Is it possible not to have the "no". I would see something like: "the application will restart, press [yes, ok,**] when ready"
Thks
CodePudding user response:
The type [System.Windows.Messagebox]
has multiple overloaded versions of the show
method, which allow various options to be set.
Here is a simple example using the version of show
which takes a string representing the message text, a string representing the message title, and a [System.Windows.MessageBoxButton]
indicating which buttons to place in the message box:
[System.Windows.MessageBox]::Show('This is my message text','Message Title',[System.Windows.MessageBoxButton]::Ok)
You can review the various types of System.Windows.MessageBoxButtons
to see what works best for your situation.
CodePudding user response:
Showing all the overloads:
Add-Type -assemblyname PresentationFramework
[Windows.MessageBox]::Show
OverloadDefinitions
-------------------
static System.Windows.MessageBoxResult Show(string messageBoxText, string caption, System.Windows.MessageBoxButton button, System.Windows.MessageBoxImage icon, System.Windows.MessageBoxResult
defaultResult, System.Windows.MessageBoxOptions options)
static System.Windows.MessageBoxResult Show(string messageBoxText, string caption, System.Windows.MessageBoxButton button, System.Windows.MessageBoxImage icon, System.Windows.MessageBoxResult
defaultResult)
static System.Windows.MessageBoxResult Show(string messageBoxText, string caption, System.Windows.MessageBoxButton button, System.Windows.MessageBoxImage icon)
static System.Windows.MessageBoxResult Show(string messageBoxText, string caption, System.Windows.MessageBoxButton button)
static System.Windows.MessageBoxResult Show(string messageBoxText, string caption)
static System.Windows.MessageBoxResult Show(string messageBoxText)
static System.Windows.MessageBoxResult Show(System.Windows.Window owner, string messageBoxText, string caption, System.Windows.MessageBoxButton button, System.Windows.MessageBoxImage icon,
System.Windows.MessageBoxResult defaultResult, System.Windows.MessageBoxOptions options)
static System.Windows.MessageBoxResult Show(System.Windows.Window owner, string messageBoxText, string caption, System.Windows.MessageBoxButton button, System.Windows.MessageBoxImage icon,
System.Windows.MessageBoxResult defaultResult)
static System.Windows.MessageBoxResult Show(System.Windows.Window owner, string messageBoxText, string caption, System.Windows.MessageBoxButton button, System.Windows.MessageBoxImage icon)
static System.Windows.MessageBoxResult Show(System.Windows.Window owner, string messageBoxText, string caption, System.Windows.MessageBoxButton button)
static System.Windows.MessageBoxResult Show(System.Windows.Window owner, string messageBoxText, string caption)
static System.Windows.MessageBoxResult Show(System.Windows.Window owner, string messageBoxText)