Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

MessageBoxResult Enumeration

Specifies which message box button that a user clicks. MessageBoxResult is returned by the Show method.

Namespace: System.Windows
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public enum MessageBoxResult
public enum MessageBoxResult
public enum MessageBoxResult
<object property="EnumerationValue" .../>

 Member nameDescription
CancelThe result value of the message box is Cancel
NoThe result value of the message box is No
NoneThe message box returns no result. 
OKThe result value of the message box is OK
YesThe result value of the message box is Yes

Show returns a MessageBoxResult value that specifies which button on a message box a user clicked. MessageBoxButton specifies which buttons are displayed on a message box.

The result value that is returned from a message box depends on what buttons the message box has and how a user closes a message box:

  • On a message box that has an OK button, OK is returned if a user clicks the OK button, clicks the Close button in the title bar, or presses the ESC key.

  • On a message box that has an OK button and a Cancel button, OK is returned if a user clicks the OK button. If a user clicks the Cancel button or the Close button in the title bar, Cancel is returned.

  • On a message box that has a Yes button and a No button, the Close button in the title bar is disabled. Consequently, Yes is returned if a user clicks the Yes button, and No is returned if a user clicks the No button.

  • On a message box that has a Yes button, a No button, and a Cancel button, Yes is returned if the Yes button is clicked and No is returned if the No button is clicked. If a user clicks the Cancel button or the Close button in the title bar, Cancel is returned.

For more information, see MessageBox Sample.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft