Share via


IManagementUIService.ShowMessage Method

Definition

Displays the specified message in a message box.

Overloads

ShowMessage(String, String)

Displays the specified message in a message box with the specified caption.

ShowMessage(String, String, MessageBoxButtons, MessageBoxIcon)

Displays the specified message in a message box with the specified caption, buttons, and icon.

ShowMessage(String, String, MessageBoxButtons, MessageBoxIcon, MessageBoxDefaultButton)

Displays the specified message in a message box with the specified caption, buttons, icon, and default button.

ShowMessage(String, String)

Displays the specified message in a message box with the specified caption.

public:
 void ShowMessage(System::String ^ text, System::String ^ caption);
public void ShowMessage (string text, string caption);
abstract member ShowMessage : string * string -> unit
Public Sub ShowMessage (text As String, caption As String)

Parameters

text
String

The message to display.

caption
String

The caption for the message box.

Examples

The following example implements this method.

private IWin32Window DialogOwner {
    get {
        return _curWin.Peek();
    }
} 
void IManagementUIService.ShowMessage(string text, string caption) {
    ShowMessage(DialogOwner,
        _owner.Title,         // member var init in MyUI_Srvc ctor
        caption,
        text,
        MessageBoxIcon.Information,
        MessageBoxButtons.OK,
        MessageBoxDefaultButton.Button1);
} 
internal DialogResult ShowMessage(
    IWin32Window owner,
    string appTitle,
    string caption, string text,
    MessageBoxIcon icon,
    MessageBoxButtons buttons,
    MessageBoxDefaultButton defaultButton) {

    if (String.IsNullOrEmpty(caption)) {
        caption = appTitle;
    }

    MessageBoxOptions options = (MessageBoxOptions)0;

    if ((owner is Control && owner != null &&
        ((Control)owner).RightToLeft == RightToLeft.Yes) ||
        _rightToLeft) {
        options |= MessageBoxOptions.RtlReading |
            MessageBoxOptions.RightAlign;
    }

    return MessageBox.Show(owner, text, caption,
        buttons, icon, defaultButton, options);
} 

Applies to

ShowMessage(String, String, MessageBoxButtons, MessageBoxIcon)

Displays the specified message in a message box with the specified caption, buttons, and icon.

public:
 System::Windows::Forms::DialogResult ShowMessage(System::String ^ text, System::String ^ caption, System::Windows::Forms::MessageBoxButtons buttons, System::Windows::Forms::MessageBoxIcon icon);
public System.Windows.Forms.DialogResult ShowMessage (string text, string caption, System.Windows.Forms.MessageBoxButtons buttons, System.Windows.Forms.MessageBoxIcon icon);
abstract member ShowMessage : string * string * System.Windows.Forms.MessageBoxButtons * System.Windows.Forms.MessageBoxIcon -> System.Windows.Forms.DialogResult
Public Function ShowMessage (text As String, caption As String, buttons As MessageBoxButtons, icon As MessageBoxIcon) As DialogResult

Parameters

text
String

The message to display.

caption
String

The caption for the message box.

buttons
MessageBoxButtons

One of the MessageBoxButtons values that specifies which buttons to display in the message box.

icon
MessageBoxIcon

One of the MessageBoxIcon values that specifies which icon to display in the message box.

Returns

One of the DialogResult values.

Examples

The following example implements this method.

private IWin32Window DialogOwner {
    get {
        return _curWin.Peek();
    }
} 
DialogResult IManagementUIService.ShowMessage(
string text,
string caption,
MessageBoxButtons buttons,
MessageBoxIcon icon
) {
    return ShowMessage(DialogOwner,
        _owner.Title,         // member var init in MyUI_Srvc ctor
        caption,
        text,
        icon,
        buttons,
        MessageBoxDefaultButton.Button1);
} 
internal DialogResult ShowMessage(
    IWin32Window owner,
    string appTitle,
    string caption, string text,
    MessageBoxIcon icon,
    MessageBoxButtons buttons,
    MessageBoxDefaultButton defaultButton) {

    if (String.IsNullOrEmpty(caption)) {
        caption = appTitle;
    }

    MessageBoxOptions options = (MessageBoxOptions)0;

    if ((owner is Control && owner != null &&
        ((Control)owner).RightToLeft == RightToLeft.Yes) ||
        _rightToLeft) {
        options |= MessageBoxOptions.RtlReading |
            MessageBoxOptions.RightAlign;
    }

    return MessageBox.Show(owner, text, caption,
        buttons, icon, defaultButton, options);
} 

Applies to

ShowMessage(String, String, MessageBoxButtons, MessageBoxIcon, MessageBoxDefaultButton)

Displays the specified message in a message box with the specified caption, buttons, icon, and default button.

public:
 System::Windows::Forms::DialogResult ShowMessage(System::String ^ text, System::String ^ caption, System::Windows::Forms::MessageBoxButtons buttons, System::Windows::Forms::MessageBoxIcon icon, System::Windows::Forms::MessageBoxDefaultButton defaultButton);
public System.Windows.Forms.DialogResult ShowMessage (string text, string caption, System.Windows.Forms.MessageBoxButtons buttons, System.Windows.Forms.MessageBoxIcon icon, System.Windows.Forms.MessageBoxDefaultButton defaultButton);
abstract member ShowMessage : string * string * System.Windows.Forms.MessageBoxButtons * System.Windows.Forms.MessageBoxIcon * System.Windows.Forms.MessageBoxDefaultButton -> System.Windows.Forms.DialogResult
Public Function ShowMessage (text As String, caption As String, buttons As MessageBoxButtons, icon As MessageBoxIcon, defaultButton As MessageBoxDefaultButton) As DialogResult

Parameters

text
String

The message to display.

caption
String

The caption for the message box.

buttons
MessageBoxButtons

One of the MessageBoxButtons values that specifies which buttons to display in the message box.

icon
MessageBoxIcon

One of the MessageBoxIcon values that specifies which icon to display in the message box.

defaultButton
MessageBoxDefaultButton

One of the MessageBoxDefaultButton values that specifies which button in the message box is the default button.

Returns

One of the DialogResult values.

Examples

The following example implements this method.

DialogResult IManagementUIService.ShowMessage(
string text,
string caption,
MessageBoxButtons buttons,
MessageBoxIcon icon
) {
    return ShowMessage(DialogOwner,
        _owner.Title,         // member var init in MyUI_Srvc ctor
        caption,
        text,
        icon,
        buttons,
        MessageBoxDefaultButton.Button1);
} 

Applies to