Back to Devexpress

XtraMessageBox.Show(XtraMessageBoxArgs) Method

windowsforms-devexpress-dot-xtraeditors-dot-xtramessagebox-dot-show-x28-devexpress-dot-xtraeditors-dot-xtramessageboxargs-x29.md

latest4.6 KB
Original Source

XtraMessageBox.Show(XtraMessageBoxArgs) Method

Displays an XtraMessageBox with the specified settings.

Namespace : DevExpress.XtraEditors

Assembly : DevExpress.XtraEditors.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
public static DialogResult Show(
    XtraMessageBoxArgs args
)
vb
Public Shared Function Show(
    args As XtraMessageBoxArgs
) As DialogResult

Parameters

NameTypeDescription
argsXtraMessageBoxArgs

An XtraMessageBoxArgs object that allows you to dynamically customize the displayed dialog.

|

Returns

TypeDescription
DialogResult

A DialogResult enumerator value that specifies which message box button an end-user has clicked.

|

Remarks

You can handle the Showing event for the args parameter to dynamically customize the message box content and buttons. The code below illustrates an example.

csharp
XtraMessageBoxArgs args = new XtraMessageBoxArgs();
args.Showing += Args_Showing;
args.Caption = "Default Text";
args.Buttons = new DialogResult[] { DialogResult.OK, DialogResult.Cancel };
XtraMessageBox.Show(args);

//...
private void Args_Showing(object sender, XtraMessageShowingArgs e) {
    e.MessageBoxForm.Text = "Custom Text";
    e.Buttons[DialogResult.OK].Text = "Yes";
    e.Buttons[DialogResult.Cancel].Text = "No";
}
vb
Dim args As New XtraMessageBoxArgs
AddHandler args.Showing, AddressOf Me.args_Showing
args.Caption = "Default Text"
args.Buttons = New DialogResult() {DialogResult.OK, DialogResult.Cancel}
XtraMessageBox.Show(args)

'. . .
Private Sub args_Showing(sender As Object, e As XtraMessageShowingArgs)
    e.MessageBoxForm.Text = "Custom Text"
    e.Buttons(DialogResult.OK).Text = "Yes"
    e.Buttons(DialogResult.Cancel).Text = "No"
End Sub

As a result, the displayed message box will have content and button captions that differ from those that were initially set.

See the XtraMessageBox article for more examples.

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

See Also

XtraMessageBox Class

XtraMessageBox Members

DevExpress.XtraEditors Namespace