赞
踩
SplashScreenManager实现Loading窗体以及Wait窗体的基本应用
1.首先:添加一个SplashScreenManager控件到窗体上,项目下会多出一个SplashScreen1.cs
2.然后设计SplashScreen窗体,打开窗体设计器,该窗体有图片,提示信息,进度条等组成,右键每个控件可以进行相应的属性设置
3.在主程序中编写代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraSplashScreen;
namespace Office7._1
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
SplashScreenManager.ShowForm(typeof(SplashScreen1)); //ShowForm方法显示LoadIng窗口
Thread.Sleep(5000); //为展示效果,将线程延迟设置为5秒
SplashScreenManager.CloseForm(); //关闭加载窗口
Application.Run(new Form1());
}
}
}
运行效果图:
4.SplashScreenManager来添加WaitForm
在主窗体中添加一个按钮,通过点击事件来实现WaitForm窗体
在点击事件中,添加代码:
using System;
using System.Threading;
using System.Windows.Forms;
using DevExpress.XtraSplashScreen;
using Office7._1;
namespace Office7._1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
SplashScreenManager.ShowForm(typeof(WaitForm1));
Thread.Sleep(5000);
SplashScreenManager.CloseForm();
}
}
}
效果图:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。