c# 一个小问题 希望大虾指点

来源:百度知道 编辑:UC知道 时间:2024/06/16 03:23:21
我在弄一个淡入淡出的欢迎界面
代码是这样的:
private void Form1_Load(object sender, EventArgs e)
{
this.ClientSize = this.BackgroundImage.Size;
this.Opacity = 0;
this.timer1.Interval = 50;
this.timer1.Enabled = true;
this.timer1.Start();

}

}

private void timer1_Tick(object sender, EventArgs e)
{
if (isFade)
{
this.Opacity += 0.02;

if (this.Opacity >= 1)
{
isFade = false;
}
}
else
{
this.Opacity -= 0.02;
if (this.Opacity <= 0)
{
this.timer1.Stop();
this.Close();

可以设置this.Visible = false;
Form2 form2 = new Form2();
form2.ShowDialog();
代替掉this.Close();
或者把
Form2 form2 = new Form2();
form2.ShowDialog();
写在this.Close()后面
=====================================
我试过了,没问题啊,你把完整的代码帖出来看看

if (this.Opacity <= 0)
{
this.timer1.Stop();
Form2 frm=new Form2();
frm.show();
this.Close();//记得写到close后面也是可以的

}
或者右键窗体属性里找到闪电符号,里面有一个close事件,写到里面去
把你写的代码拿出来
我分析下,应该不会被close

如果是欢迎界面,在主程序入口打开该窗体。
然后继续打开主窗体就可以了。
最好在你这个欢迎界面写一个静态函数打开自己。
然后在主程序入口,打开主窗体前,调用一下该函数。就ok