WizardPage.ShowMessage Method

Definition

Displays a message box that uses the specified text.

Overloads

ShowMessage(String)

Displays a message box that uses the specified text.

ShowMessage(String, MessageBoxButtons, MessageBoxIcon, MessageBoxDefaultButton)

Displays a message box that uses the specified text, button set, symbol, and default button.

ShowMessage(String)

Displays a message box that uses the specified text.

protected:
 void ShowMessage(System::String ^ text);
protected void ShowMessage (string text);
member this.ShowMessage : string -> unit
Protected Sub ShowMessage (text As String)

Parameters

text
String

The message to display.

Remarks

This overloaded method displays a message box that contains only an OK button, which is defined by the System.Windows.Forms.MessageBoxButtons enumeration.

Applies to

ShowMessage(String, MessageBoxButtons, MessageBoxIcon, MessageBoxDefaultButton)

Displays a message box that uses the specified text, button set, symbol, and default button.

protected:
 System::Windows::Forms::DialogResult ShowMessage(System::String ^ text, System::Windows::Forms::MessageBoxButtons buttons, System::Windows::Forms::MessageBoxIcon icon, System::Windows::Forms::MessageBoxDefaultButton defaultButton);
protected System.Windows.Forms.DialogResult ShowMessage (string text, System.Windows.Forms.MessageBoxButtons buttons, System.Windows.Forms.MessageBoxIcon icon, System.Windows.Forms.MessageBoxDefaultButton defaultButton);
member this.ShowMessage : string * System.Windows.Forms.MessageBoxButtons * System.Windows.Forms.MessageBoxIcon * System.Windows.Forms.MessageBoxDefaultButton -> System.Windows.Forms.DialogResult
Protected Function ShowMessage (text As String, buttons As MessageBoxButtons, icon As MessageBoxIcon, defaultButton As MessageBoxDefaultButton) As DialogResult

Parameters

text
String

The message to display in the message box.

buttons
MessageBoxButtons

One of the MessageBoxButtons values.

icon
MessageBoxIcon

One of the MessageBoxIcon values.

defaultButton
MessageBoxDefaultButton

One of the MessageBoxDefaultButton values.

Returns

One of the DialogResult values.

Examples

The following example demonstrates the ShowMessage(String, MessageBoxButtons, MessageBoxIcon, MessageBoxDefaultButton) overload. This example displays a message box that contains Yes and No buttons and an information symbol, and it provides the user an opportunity to cancel the operation. This code example is part of a larger example provided for the WizardPage class.

// Customize the CanNavigateNext property. This property
// is set to false until the user is validated.
private void button1_Click(object sender, EventArgs e)
{
    // Perform user validation checks. If this is a valid
    // user move to the next page. If the user is not a valid
    // user, exit the application.
    // User validation.
    string text = "Did the user pass validation?";
    MessageBoxButtons buttons = MessageBoxButtons.YesNo;
    MessageBoxIcon icon = MessageBoxIcon.Information;
    MessageBoxDefaultButton defaultButton = MessageBoxDefaultButton.Button2;
    DialogResult result = ShowMessage(text, buttons, icon, defaultButton);
    if (result == DialogResult.No)
    {
        Application.Exit();
    }
    else
    {
        _canNavigateNext = true;
        this.UpdateWizard();
        ShowHelp();
    }
}
protected new DialogResult ShowMessage(string text, 
    MessageBoxButtons buttons,
    MessageBoxIcon icon, 
    MessageBoxDefaultButton defaultButton)
{
    return base.ShowMessage(text + " Yes or No.", buttons, icon, defaultButton);
}

Remarks

This method enables you to create a custom ShowMessage method. You can check the return System.Windows.Forms.DialogResult value from this method to determine the user's actions.

Applies to