这可能看起来是一个简单的问题...
我正在寻找在C# Winforms中的Label.Opacity属性。
我想要做的事情是有一个方法逐渐淡出一个标签。也许通过一个定时器实现?
由于没有Opacity属性,我试图将其透明度设置为更高的数字,直到它足够高,该项应该是不可见的。但是我似乎无法使其起作用。
目前我有:
public FadeLabel()
{
MyTimer timer = new MyTimer();
this.TextChanged += (s, ea) =>
{
if (timer.IsActive)
{
timer.Reset();
}
else
{
timer.WaitTime.Miliseconds = 500;
timer.Start();
timer.Completed += (a) =>
{
int i = 0;
Timer tm = new Timer();
tm.Interval = 1;
tm.Tick += (sa, aea) =>
{
i++;
this.ForeColor = Color.FromArgb(i, Color.Black);
this.BackColor = Color.FromArgb(i, Color.White);
this.Invalidate();
if (i == 255)
{
tm.Stop();
}
};
tm.Start();
};
}
};
}