How to: Open a Message Box
This example shows how to open a message box.
Example
A message box is a prefabricated modal dialog box for displaying information to users. A message box is opened by calling the static Show method of the MessageBox class. When Show is called, the message is passed using a string parameter. Several overloads of Show allow you to configure how a message box will appear (see MessageBox).
private void ShowMessageBoxButton_Click(object sender, RoutedEventArgs e)
{
// Configure message box
string message = "Hello, MessageBox!";
// Show message box
MessageBoxResult result = MessageBox.Show(message);
}
Private Sub showMessageBoxButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
' Configure message box
Dim message As String = "Hello, MessageBox!"
' Show message box
Dim result As MessageBoxResult = MessageBox.Show(message)
End Sub
See also
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
.NET Desktop feedback