visual studio 2005 C#做软件欢迎窗体遇到label控件无法显示,请高手来帮忙看看

2024-12-02 17:44:10
推荐回答(3个)
回答1:

namespace test
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Form2 fw = new Form2();
fw.Show();
Application.DoEvent();
System.Threading.Thread.Sleep(3000);
fw.Close();
}
}
}

回答2:

因为System.Threading.Thread.Sleep(3000);这句阻塞了主线程,没有“人”负责绘制主窗体,所以窗体便卡在那里,在Form2里加一个Timer控件就行了,代码如下
Form1
public Form1()
{
InitializeComponent();
Form2 fw = new Form2();
fw.ShowDialog();
}

Form2:先设置好timer1的Interval=1000,Enabled =true
int times = 0;
private void timer1_Tick(object sender, EventArgs e)
{
times++;
if (times == 3)
{
this.Close();
}
}

回答3:

fw.refresh();