With this the default is OK. Can I make the default Cancel?
MessageBoxResult result = MessageBox.Show
(message, caption, MessageBoxButton.OKCancel);
How to open a message box (WPF .NET) 1 Display a message box. To create a message box, you use the MessageBox class. ... The MessageBox.Show method overloads... 2 Handle a message box response. The MessageBox.Show method displays the message box and returns a result. ... When a... 3 See also. More ...
Use this overload, which allows you to specify the default MessageBoxResult: MessageBoxResult result = MessageBox.Show (message, caption, MessageBoxButton.OKCancel, MessageBoxImage.Information, MessageBoxResult.Cancel);
By simply using MessageBoxButton.YesNo in the Show method, a MessageBox with OK and Cancel buttons is created. The following code snippet creates a MessageBox with a message, a title, and two OK and Cancel buttons: The output looks as in Figure 7.
A message box is a dialog box that is used to quickly display information and optionally allow users to make decisions. Access to the message box is provided by the MessageBox class. A message box is displayed modally.
Use this overload, which allows you to specify the default MessageBoxResult
:
MessageBoxResult result = MessageBox.Show
(message, caption, MessageBoxButton.OKCancel,
MessageBoxImage.Information, MessageBoxResult.Cancel);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With