
1.先创建一个WaitForm 的窗体,或者随便Form窗体,只需要继承WaitForm窗体就行。
2.把控件拉入窗体,调整为合适的大小。
3.设置控件的样式,DevExpress给等待框默认设置了非常多的样式,如图2 设置,UseDefaultLookAndFeel设置为False,即不采用默认样式,这样系统就会取SkinName设置的样式。

4.WaitForm后台常用设置代码
public partial class AppWaitForm : WaitForm
{
public AppWaitForm()
{
InitializeComponent();
this.progressPanel.AutoHeight = true;
}
#region Overrides
public override void SetCaption(string caption)
{
base.SetCaption(caption);
this.progressPanel.Caption = caption;
}
public override void SetDescription(string description)
{
base.SetDescription(description);
this.progressPanel.Description = description;
}
public override void ProcessCommand(Enum cmd, object arg)
{
base.ProcessCommand(cmd, arg);
}
#endregion
}
5.窗体调用该控件的方法。
5.1 先在需要使用的窗体上拖入控件SplashScreenManager。如图3

5.2 属性ActiveSplashFormTypeInfo是设置该控件关联到我们之前写的WaitForm窗体,如图4.

5.3 后台调用代码如下:
private void LoginView_Load(object sender, EventArgs e)
{
splashScreenManager.ShowWaitForm();
//上部分提示
splashScreenManager.SetWaitFormCaption("请等待");
//下面长描述
splashScreenManager.SetWaitFormDescription("加载中...");
Init();
//关闭时判断是否等待窗体是否正在运行
if (splashScreenManager.IsSplashFormVisible)
splashScreenManager.CloseWaitForm();
}
6.等待窗体的各种样式:图5

文章评论