开发者论坛

 找回密码
 注册 (请使用非IE浏览器)
查看: 6138|回复: 0

表单控件 - 动态更新Wait Form的标题或描述

[复制链接]

0

精华

8

贡献

1768

赞扬

特约版主

帖子
583
软币
4524
在线时间
275 小时
注册时间
2019-2-21
发表于 2021-3-4 10:18:35 | 显示全部楼层 |阅读模式

点击获取DevExpress完整版下载

启动屏幕管理器在单独的线程中显示Wait Form,若要在显示Wait Form时动态更改标签,请使用SplashScreenManager.SetWaitFormCaption和SetWaitFormDescription方法。

注意:完成的示例项目位于https://github.com/DevExpress-Examples/how-to-dynamically-change-a-wait-forms-labels-e3575

Form1.cs

[CSS] 纯文本查看 复制代码
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);
}
}
}

Form1.vb

[C#] 纯文本查看 复制代码
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


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

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


回复

使用道具 举报

Archiver|手机版|小黑屋|开发者网 ( 苏ICP备08004430号-2 )
版权所有:南京韵文教育信息咨询有限公司

GMT+8, 2024-11-21 20:57

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表