您的位置:首页 > 编程语言 > C#

C#一个渐变并且消失的窗体

2009-07-17 11:00 176 查看
using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

namespace WindowsApplication3

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

private void Form1_Load(object sender, EventArgs e)

{

this.timer1.Enabled = true;//获取当前运行时间

this.Opacity = 1;//获取当前窗体的透明度级别;

}

private void timer1_Tick(object sender, EventArgs e)

{

if (this.Opacity >0.9)

{

this.Opacity = this.Opacity -0.01;//窗体以0.01的速度渐变

}

else if (this.Opacity < 0)

{

this.timer1.Enabled = false;//时间为false

}

else

{

Close();///渐变消失

}

}

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: