Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

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.v24.2.dll

NuGet Package: DevExpress.Win.Navigation

#Declaration

public AutoCloseOptions AutoCloseOptions { get; set; }

#Property Value

Type Description
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.

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();

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.

MessageBox - CountDown

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;
See Also