XtraMessageBox.Show(XtraMessageBoxArgs) Method
Displays an XtraMessageBox with the specified settings.
Namespace: DevExpress.XtraEditors
Assembly: DevExpress.XtraEditors.v24.2.dll
NuGet Package: DevExpress.Win.Navigation
#Declaration
public static DialogResult Show(
XtraMessageBoxArgs args
)
#Parameters
Name | Type | Description |
---|---|---|
args | Xtra |
An Xtra |
#Returns
Type | Description |
---|---|
Dialog |
A Dialog |
#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.
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";
}
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.
The following list shows the default parameters of the Show method overloads. You can override these parameters using a specific Show method overload.
- Caption - Empty string
- Buttons - MessageBoxButtons.OK
- Owner - null
- Icon - MessageBoxIcon.None
- DefaultButton - MessageBoxDefaultButton.Button1
- XtraMessageBox.AllowHtmlText - DefaultBoolean.Default
#Example
This example demonstrates how to display the XtraMessageBox
.
using DevExpress.XtraEditors;
using DevExpress.Utils;
private void simpleButton1_Click(object sender, EventArgs e) {
if(XtraMessageBox.Show("Do you want to close the <b>form</b>?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, DefaultBoolean.True) == DialogResult.Yes)
this.Close();
}