Back to Devexpress

XtraBaseArgs.AutoCloseOptions Property

windowsforms-devexpress-dot-xtraeditors-dot-xtrabaseargs-5ffc8ada.md

latest3.1 KB
Original Source

XtraBaseArgs.AutoCloseOptions Property

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

Declaration

csharp
public AutoCloseOptions AutoCloseOptions { get; set; }
vb
Public Property AutoCloseOptions As AutoCloseOptions

Property Value

TypeDescription
AutoCloseOptions

Provides access to auto-close settings.

|

Remarks

The code below utilizes the AutoCloseOptions.Delay to make the XtraMessageBox automatically close 5 seconds after it was shown.

csharp
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();
vb
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.

csharp
// change the default button
 args.DefaultButtonIndex = 1;
// set to false to hide the countdown
args.AutoCloseOptions.ShowTimerOnDefaultButton = false;
vb
' change the default button
 args.DefaultButtonIndex = 1
' set to false to hide the countdown
args.AutoCloseOptions.ShowTimerOnDefaultButton = False

See Also

XtraBaseArgs Class

XtraBaseArgs Members

DevExpress.XtraEditors Namespace