windowsforms-devexpress-dot-xtraeditors-dot-xtrabaseargs-5ffc8ada.md
Provides access to settings that allow the shown object (XtraMessageBox, XtraInputBox, etc.) to automatically close after a certain delay.
Namespace : DevExpress.XtraEditors
Assembly : DevExpress.XtraEditors.v25.2.dll
NuGet Package : DevExpress.Win.Navigation
public AutoCloseOptions AutoCloseOptions { get; set; }
Public Property AutoCloseOptions As AutoCloseOptions
| Type | Description |
|---|---|
| AutoCloseOptions |
Provides access to auto-close settings.
|
The code below utilizes the AutoCloseOptions.Delay to make the XtraMessageBox automatically close 5 seconds after it was shown.
XtraMessageBoxArgs args = new XtraMessageBoxArgs();
args.AutoCloseOptions.Delay = 5000;
args.AutoCloseOptions.ShowTimerOnDefaultButton = true;
args.Caption = "Auto-close message";
args.Text = "This message closes automatically after 5 seconds.";
args.Buttons = new DialogResult[] { DialogResult.OK, DialogResult.Cancel};
XtraMessageBox.Show(args).ToString();
Dim args As New XtraMessageBoxArgs()
args.AutoCloseOptions.Delay = 5000
args.AutoCloseOptions.ShowTimerOnDefaultButton = True
args.DefaultButtonIndex = 0
args.Caption = "Auto-close message"
args.Text = "This message closes automatically after 5 seconds."
args.Buttons = New DialogResult() { DialogResult.OK, DialogResult.Cancel}
XtraMessageBox.Show(args).ToString()
The first message box button (“OK” in the sample above) is a default button - if a user presses “Enter” or the auto-closing timer expires, this button is considered clicked, and the message box returns the corresponding DialogResult value. This button also displays the countdown timer for auto-closing messages.
You can modify the XtraMessageBoxArgs.DefaultButtonIndex to select the default button and disable the AutoCloseOptions.ShowTimerOnDefaultButton setting to hide the countdown timer.
// change the default button
args.DefaultButtonIndex = 1;
// set to false to hide the countdown
args.AutoCloseOptions.ShowTimerOnDefaultButton = false;
' change the default button
args.DefaultButtonIndex = 1
' set to false to hide the countdown
args.AutoCloseOptions.ShowTimerOnDefaultButton = False
See Also