Hi friends today lets discuss about how to create animated label in windows forms.
- Once open the Visual Studio click on File Click on the Project .
- Select on Windows Forms Application
- Change the name as per your requirement
- Right Click on the project and add a form and rename as Animated_Label_Demo
- Add a new label and change the text as Animated Label
- From ToolBox Select a Timer and drag and drop on windows form
Right click on the time and Enable into TRUE and change the interval as per your requirement
Lets look into code behind file
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class AninatedLabel : Form
{
public AninatedLabel()
{
InitializeComponent();
}
}
}
Double Click on the timer . you will get a timer event timer1_Tick. Have a look on the above code we need to apply animation to a label This event will fire and color will change
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class AninatedLabel : Form
{
public AninatedLabel()
{
InitializeComponent();
}
private void timer1_Tick(object sender, EventArgs e) // timer event
{
if (label1.BackColor != Color.Red)
label1.BackColor = Color.Red;
else
label1.BackColor = Color.Green;
}
}
}
Output :
Conclusion
In this article we have seen how apply animation to the label in windows form.