DevExpress控件使用交流,DevExpress中国社区Dev联系电话 联系电话:023-68661681

DevExpress WinForms帮助文档:表单和用户控件 -等待表单

来源:   发布时间:2021-03-30   浏览:1370次

点击获取DevExpress完整版下载

初始屏幕管理器允许您创建一个等待表单(WaitForm) - 一种旨在识别皮肤的表单,用于指示耗时的操作。

DevExpress WinForms帮助文档

主要功能包括:

  • 动画的连续进度指示器。
  • 您可以在代码中显示关闭等待表单。
  • 设计时自定义。
  • 通过命令与等待表单进行交互。
  • 默认外观设置取决于皮肤。
DevExpress WinForms帮助文档
创建和自定义等待表单

SplashScreenManager 组件拖放到窗体上,右键单击Visual Studio托盘中的组件,然后选择Add Wait Form。

DevExpress WinForms帮助文档

SplashScreenManager将新的WaitForm添加到您的项目。

DevExpress WinForms帮助文档

要在设计时查看和自定义等待表单,请在Solution Explorer中双击WaitForm1.cs(WaitForm1.vb)文件。

DevExpress WinForms帮助文档

使用属性网格更改内置ProgressPanel的显示设置,此面板显示动画进度指示器和标签。

DevExpress WinForms帮助文档

注意:如果需要使用自定义类扩展WaitForm1.cs/.vb文件,请确保封装Wait Form的类在这些文件中排在第一位。

DevExpress WinForms帮助文档
显示和隐藏等待表单

等待表单不会在主表单启动时自动显示。 您可以使用以下方法显示和关闭等待表单,具体取决于等待表单是否处于激活状态(已分配给 SplashScreenManager.ActiveSplashFormTypeInfo属性)。

  • 目标等待表单处于激活状态。
DevExpress WinForms帮助文档

要显示/关闭等待表单,请使用非静态的SplashScreenManager.ShowWaitFormSplashScreenManager.CloseWaitForm方法。

C#

splashScreenManager1.ShowWaitForm();
//...
splashScreenManager1.CloseWaitForm();

VB.NET

splashScreenManager1.ShowWaitForm()
'...
splashScreenManager1.CloseWaitForm()
  • 目标等待表单未激活。
DevExpress WinForms帮助文档

要显示/关闭等待表单,请使用静态SplashScreenManager.ShowFormSplashScreenManager.CloseForm方法。 特定的SplashScreenManager.ShowForm方法重载允许您指定淡入淡出效果和等待表单位置。

C#

SplashScreenManager.ShowForm(typeof(WaitForm1));
//...
SplashScreenManager.CloseForm();

VB.NET

SplashScreenManager.ShowForm(GetType(WaitForm1))
'...
SplashScreenManager.CloseForm()
动态更新等待表单

与其他初始屏幕一样,等待表单也显示在单独的线程中。

使用以下方法从主线程动态更新显示等待表单的标题和描述:

您还可以使用SplashScreenManager.SendCommand方法与当前的等待表单进行交互(例如,更新其内容)。 要处理此方法发送的命令,请重写WaitForm.ProcessCommand方法。

使用说明

显示多个等待表单

如果您的应用程序一次只显示一个等待表单,则可以使用单个SplashScreenManager组件。

若要同时显示多个等待表单,请使用多个SplashScreenManager组件。

MDI应用

在MDI应用程序中,不要显示Control.CreateHandle方法调用的事件或方法的等待表单 - HandleCreated,Load,MdiChildActivate,OnHandleCreated重载等,否则您的应用程序可能会冻结。

而是,使用以下方法:

C#

//Incorrect - the app may freeze
private void MdiParent_MdiChildActivate(object sender, EventArgs e) {
//...
splashScreenManager1.ShowWaitForm();
splashScreenManager1.SetWaitFormCaption("Please wait");
splashScreenManager1.SetWaitFormDescription(description);
//...
splashScreenManager1.CloseWaitForm();
}

//Correct
private void MdiParent_MdiChildActivate(object sender, EventArgs e) {
BeginInvoke(new Action(() => {
//...
splashScreenManager1.ShowWaitForm();
splashScreenManager1.SetWaitFormCaption("Please wait");
splashScreenManager1.SetWaitFormDescription(description);
//...
splashScreenManager1.CloseWaitForm();
}));
}

VB.NET

'Incorrect - the app may crash
Private Sub MdiParent_MdiChildActivate(ByVal sender As Object, ByVal e As EventArgs)
'...
splashScreenManager1.ShowWaitForm()
splashScreenManager1.SetWaitFormCaption("Please wait")
splashScreenManager1.SetWaitFormDescription(description)
'...
splashScreenManager1.CloseWaitForm()
End Sub

'Correct
Private Sub MdiParent_MdiChildActivate(ByVal sender As Object, ByVal e As EventArgs)
BeginInvoke(New Action(Sub()
'...
splashScreenManager1.ShowWaitForm()
splashScreenManager1.SetWaitFormCaption("Please wait")
splashScreenManager1.SetWaitFormDescription(description)
'...
splashScreenManager1.CloseWaitForm()
End Sub))
End Sub

上DevExpress中文网,获取第一手最新产品资讯!

DevExpress技术交流群3:700924826      欢迎一起进群讨论

慧都高端UI界面开发
本站文章除注明转载外,均为本站原创或翻译
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:DevExpress控件中文网 [https://www.devexpresscn.com/]
本文地址:https://www.devexpresscn.com/post/2328.html

相关产品: DevExpress Universal Subscription,

在线
客服
微信
QQ 电话
023-68661681
返回
顶部