Skip to main content
All docs
V25.1
  • 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.1.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