DevExpress使用WaitForm等待加载窗体

DevExpress中除过WaitDialogForm,还有WaitForm,也可以实现此功能,WaitForm比WaitDialogForm更加的强大。

1.建立一个项目

2.增加 WaitForm窗体。

右键项目选择New Item

选择如图所示

 这个是修改字体的颜色

 这个是修改窗体的样式,

 有4种样式可以选择

 3.在代码中增加

   public void ShowMe(Form owner, string description, string caption)
        {
            SplashScreenManager.ShowForm(owner, typeof(WaitForm1), true, true, false);
            SplashScreenManager.Default.SetWaitFormDescription(description);//描述
            SplashScreenManager.Default.SetWaitFormCaption(caption);//标题    
        }


        public void ShowMe(Form owner)
        {
            SplashScreenManager.ShowForm(owner, typeof(WaitForm1), true, true, false);
        }

        public void HideMe(Form owner)
        {
            SplashScreenManager.CloseForm(false, 0, owner);
        }

 4.WaitForm1中所有的代码

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraSplashScreen;
using DevExpress.XtraWaitForm;

namespace WindowsFormsApp1
{
    public partial class WaitForm1 : WaitForm
    {
        public WaitForm1()
        {
            InitializeComponent();
            this.progressPanel1.AutoHeight = true;
        }

        #region Overrides

        public override void SetCaption(string caption)
        {
            base.SetCaption(caption);
            this.progressPanel1.Caption = caption;
        }
        public override void SetDescription(string description)
        {
            base.SetDescription(description);
            this.progressPanel1.Description = description;
        }
        public override void ProcessCommand(Enum cmd, object arg)
        {
            base.ProcessCommand(cmd, arg);
        }

        #endregion

        public enum WaitFormCommand
        {
        }

        public void ShowMe(Form owner, string description, string caption)
        {
            SplashScreenManager.ShowForm(owner, typeof(WaitForm1), true, true, false);
            SplashScreenManager.Default.SetWaitFormDescription(description);//描述
            SplashScreenManager.Default.SetWaitFormCaption(caption);//标题    
        }


        public void ShowMe(Form owner)
        {
            SplashScreenManager.ShowForm(owner, typeof(WaitForm1), true, true, false);
        }

        public void HideMe(Form owner)
        {
            SplashScreenManager.CloseForm(false, 0, owner);
        }
    }
}

5.回到项目的主界面中,在按钮下面增加以下代码 

using DevExpress.XtraSplashScreen;
using System;
using System.Threading;
using System.Windows.Forms;

namespace WindowsFormsApp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            WaitForm1 waitForm1 = new WaitForm1();
            waitForm1.ShowMe(this, "123", "456");
            for (int i = 1; i <= 5; i++)//处理数据
            {
                Thread.Sleep(1000);
            }
            waitForm1.HideMe(this);
        }
    }
}

6.效果

拓展功能

在进入软件的时候,先进行加载,然后再进入软件的主界面

1.在程序入口Program中增加如下代码

SplashScreenManager.ShowForm(typeof(WaitForm1));
            Thread.Sleep(5000);

 2.在主界面中,增加load事件,增加如下代码 

SplashScreenManager.CloseForm(true);

3.效果

来源:DevExpress使用WaitForm等待加载窗体_dev waitform-CSDN博客

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

故里2130

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值