I am trying to create a class that makes a particular textbox blink. My code is below:
class Blink
{
int BlinkCount = 0;
public void Text(Label Info, string Message)
{
Timer tmrBlink = new Timer();
tmrBlink.Interval = 250;
tmrBlink.Tick += new System.EventHandler(tmrBlink_Tick);
tmrBlink.Start();
Info.Text = Message;
}
private void tmrBlink_Tick(object sender, EventArgs e)
{
BlinkCount++;
if (Info.BackColor == System.Drawing.Color.Khaki)
{
Info.BackColor = System.Drawing.Color.Transparent;
}
else
{
Info.BackColor = System.Drawing.Color.Khaki;
}
if (BlinkCount == 4)
{
tmrBlink.Stop();
}
}
}
The idea is, if I type the following code, the selected label would blink to draw user's attention:
Blink.Text(lblControl, "Hello World!");