Back to Devexpress

How to: Dynamically Update Wait Form's Caption or Description

windowsforms-10832-controls-and-libraries-forms-and-user-controls-splash-screen-manager-examples-how-to-dynamically-update-wait-forms-caption-or-description.md

latest2.6 KB
Original Source

How to: Dynamically Update Wait Form's Caption or Description

  • Aug 01, 2019
  • 2 minutes to read

A Wait Form is displayed by a Splash Screen Manager in a separate thread. To dynamically change labels within the Wait Form, while it is being displayed, use the SplashScreenManager.SetWaitFormCaption and SetWaitFormDescription methods.

View Example

csharp
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraSplashScreen;
using System.Threading;

namespace WaitForm_SetDescription {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }

        private void btnShowWaitForm_Click(object sender, EventArgs e) {
            //Open Wait Form
            SplashScreenManager.ShowForm(this, typeof(WaitForm1), true, true, false);

            //The Wait Form is opened in a separate thread. To change its Description, use the SetWaitFormDescription method.
            for (int i = 1; i <= 100; i++) {
                SplashScreenManager.Default.SetWaitFormDescription(i.ToString() + "%");
                Thread.Sleep(25);
            }

            //Close Wait Form
            SplashScreenManager.CloseForm(false);
        }
    }
}
vb
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Linq
Imports System.Text
Imports System.Windows.Forms
Imports DevExpress.XtraSplashScreen
Imports System.Threading

Namespace WaitForm_SetDescription
    Partial Public Class Form1
        Inherits Form
        Public Sub New()
            InitializeComponent()
        End Sub

        Private Sub btnShowWaitForm_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnShowWaitForm.Click
            'Open Wait Form
            SplashScreenManager.ShowForm(Me, GetType(WaitForm1), True, True, False)

            'The Wait Form is opened in a separate thread. To change its Description, use the SetWaitFormDescription method.
            For i As Integer = 1 To 100
                SplashScreenManager.Default.SetWaitFormDescription(i.ToString() & "%")
                Thread.Sleep(25)
            Next i

            'Close Wait Form
            SplashScreenManager.CloseForm(False)
        End Sub
    End Class
End Namespace