【发布时间】:2015-12-01 19:55:52
【问题描述】:
我试图让启动画面首先出现,然后在启动之后出现MainForm。但是我在初始屏幕中的进度条没有到达进度条的末尾。并且程序继续运行但不起作用。
如何在加载主窗体时显示启动画面?
我的代码是这样的:
public partial class SplashForm : Form
{
public SplashForm()
{
InitializeComponent();
}
private void SplashForm_Load(object sender, EventArgs e)
{
timer1.Enabled = true;
timer1.Start();
timer1.Interval = 1000;
progressBar1.Maximum = 10;
timer1.Tick += new EventHandler(timer1_Tick);
}
public void timer1_Tick(object sender, EventArgs e)
{
if (progressBar1.Value != 10)
{
progressBar1.Value++;
}
else
{
timer1.Stop();
Application.Exit();
}
}
}
这里是MainForm的第一部分代码:
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
Application.Run(new SplashForm());
}
}
【问题讨论】:
-
你能展示创建这个表单的代码吗? pbcarrega 在哪里初始化?
-
pbcarrega 是 ProgressBar 的名称
-
这个代码是Form Splash Screen的代码,但是你想知道Form Main吗?
-
@Novatec - 您需要向我们提供足够的代码,以便我们重现您的问题。仅仅选择几行你认为相关的代码是不够的。请发布minimal, complete, and verifiable 代码以复制您的问题。
-
我现在发布了 Form Main 的部分,我正在查看,我认为我在 Application.Run() 的那部分做错了
标签: c# .net winforms splash-screen