您必須創建您的繼承形式並覆蓋SetDescription()和SetCaption()。你會用一些圖標或GIF動畫來裝飾表單。 在下面的例子中,我創建了一個名爲MyWaitForm的表單,並且我簡單地放置了兩個標籤來顯示描述和標題文本。
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;
namespace DXApplication1
{
public partial class MyWaitForm : DevExpress.XtraWaitForm.WaitForm
{
public MyWaitForm()
{
InitializeComponent();
}
public override void SetDescription(string description)
{
base.SetDescription(description);
lbDescription.Text = description;
}
public override void SetCaption(string caption)
{
base.SetCaption(caption);
lbCaption.Text = caption;
}
}
}
這裏作爲Visual Studio設計出的MyWaitForm:
之後,你會用DevExpress的代碼示例顯示WaitForm
https://documentation.devexpress.com/#WindowsForms/CustomDocument10832
但通過你的MyWaitForm類類型添加到SplashScreenManager.ShowForm()方法中:
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 MyWaitForm!!!
SplashScreenManager.ShowForm(this, typeof(MyWaitForm), 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);
}
}
}