Back to Devexpress

XtraMessageBox.Show(String, String) Method

windowsforms-devexpress-dot-xtraeditors-dot-xtramessagebox-dot-show-x28-system-dot-string-system-dot-string-x29.md

latest5.6 KB
Original Source

XtraMessageBox.Show(String, String) Method

Displays the XtraMessageBox with the specified text and caption.

Namespace : DevExpress.XtraEditors

Assembly : DevExpress.XtraEditors.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
public static DialogResult Show(
    string text,
    string caption
)
vb
Public Shared Function Show(
    text As String,
    caption As String
) As DialogResult

Parameters

NameTypeDescription
textString

A string value that specifies the text to display in the message box.

| | caption | String |

A string value that specifies the message box’s caption.

|

Returns

TypeDescription
DialogResult

One of the DialogResult values.

|

Remarks

The following code snippet displays an XtraMessageBox with the specified text and caption:

csharp
const string text = "Hello DevExpress!";
const string caption = "Information";

XtraMessageBox.Show(text, caption);

Default Parameters

ParameterDefault ValueProperty Name
CaptionString.EmptyCaption
ButtonsMessageBoxButtons.OKButtons
DefaultButtonIndex0DefaultButtonIndex
OwnernullOwner
IconMessageBoxIcon.NoneImageOptions

The following code snippet displays the XtraMessageBox with formatted text and a warning icon. If the user clicks Yes , the application closes the current form.

csharp
using DevExpress.XtraEditors;
using DevExpress.Utils;

if(XtraMessageBox.Show(
    "Do you want to close the <b>form</b>?", "Warning",
    MessageBoxButtons.YesNo, MessageBoxIcon.Warning,
    DefaultBoolean.True) == DialogResult.Yes)
    this.Close();
vb
Imports DevExpress.XtraEditors
Imports DevExpress.Utils

If XtraMessageBox.Show("Do you want to close the <b>form</b>?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, DefaultBoolean.True) = DialogResult.Yes Then
    Me.Close()
End If

The following code snippets (auto-collected from DevExpress Examples) contain references to the Show(String, String) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-mvvm-best-practices/CS/CustomServices/CustomServiceUserControl.cs#L50

csharp
public void DoSomething() {
    XtraMessageBox.Show("Hi!", text ?? "CustomService");
}

how-to-use-custom-graph-layout-algorithms-to-arrange-shapes-in-diagramcontrol-t394210/CS/XtraDiagram.CustomLayoutAlgorithms/CustomLayoutForm.cs#L63

csharp
} catch(Exception e) {
    XtraMessageBox.Show(string.Format("Error message: '{0}'", e.Message), "Error has been occurred");
}

winforms-mvvm-best-practices/VB/CustomServices/CustomServiceUserControl.vb#L49

vb
Public Sub DoSomething() Implements ICustomService.DoSomething
    XtraMessageBox.Show("Hi!", If(text, "CustomService"))
End Sub

how-to-use-custom-graph-layout-algorithms-to-arrange-shapes-in-diagramcontrol-t394210/VB/XtraDiagram.CustomLayoutAlgorithms/CustomLayoutForm.vb#L64

vb
Catch e As Exception
    XtraMessageBox.Show(String.Format("Error message: '{0}'", e.Message), "Error has been occurred")
End Try

See Also

XtraMessageBox Class

XtraMessageBox Members

DevExpress.XtraEditors Namespace