AABBbaby

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

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

点击获取DevExpress完整版下载

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

初始屏幕管理器允许您创建一个等待表单(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中文网,获取第一手最新产品资讯!

posted on   AABBbaby  阅读(153)  评论(0编辑  收藏  举报

编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!
历史上的今天:
2020-03-31 .NET界面开发工具——DevExpress v19.2.7升级发布
点击右上角即可分享
微信分享提示