窗口淡入淡出效果

 淡入效果1

//渐显方法2:
private void ComeOn()
{
   for (double d = 0.01; d < 1; d += 0.11)
            {
                System.Threading.Thread.Sleep(15);
                Application.DoEvents();
                this.Opacity = d;
                this.Refresh();
            }
}

淡入效果2

 string caozuo = "";//窗体操作方法字符串
        private void Form1_Load(object sender, EventArgs e)
        
{
            caozuo 
= "load";//窗体操作方_打开时
            this.Opacity = 0;//设置窗体不透明度
            timer1.Start();//时间空间开始运行
        }

        
//窗体上面放置了一个按钮 执行关闭窗体操作
        private void button1_Click_1(object sender, EventArgs e)
        
{
            caozuo 
= "close";//窗体操作方法更改 关闭窗体 
        }

        
//time控件要执行的操作
        private void timer1_Tick_1(object sender, EventArgs e)
        
{
            
if (caozuo == "load")//判断操作方法
            {
                
this.Opacity += 0.03;//改变窗体透明度
            }

            
else if (caozuo == "close")//判断操作方法
            {
                
this.Opacity = this.Opacity - 0.03;//改变窗体透明度
                if (this.Opacity == 0)//当窗体透明度为0时(看不到窗体了)
                {
                    
this.Close();//关闭窗体
                }

            }

        }在设置下time控件的Interval 的值就行了,我设置的是10,你要是觉得快就把数字改点就行了,

原文地址:https://www.cnblogs.com/windphoenix/p/1467482.html