日期:2014-05-17  浏览次数:20956 次

怎么把窗体的Opacity的值随Timer变透明?
就是让窗体随时间的减少逐渐变透明。
  private int Opacity1()
  {
  int i = 0;
  Timer t1 = new Timer();
  t1.Interval = 100;
  t1.Enabled = true;
  t1.Start();
  for (i = 100; i >= 0; i--)
  {
  i = t1.Interval - 1;
  this.Opacity = i;
  }
  t1.Stop();
  return i;
  }
点击确定按钮调用Opacity1(),但窗体会卡住的。怎么办?

------解决方案--------------------
C# code

 private void FormWelcome_Load(object sender, EventArgs e)
        {
            this.Opacity = 1;   
            this.timer1.Interval = 50; 
            this.timer1.Start(); 
        }

        private void timer1_Tick_1(object sender, EventArgs e)
        {
            this.Opacity -= 0.2;
            if (this.Opacity = 0)
            {
                this.timer1.Stop();
                this.Close();
            }  
        }