Home > DeveloperSection > Forums > Line Shape in Windows Form
Jaya J
Jaya J

Total Post:9

Points:63
Posted on    March-31-2015 12:42 AM

 .NET C# 
Ratings:


 1 Reply(s)
 545  View(s)
Rate this:
I have draw a line shape in windows form using Toolbox.Now i want to Blink that line shape when button was clicked at runtime.Tell me anyone is it possible in windows form using c#..If Possible tell me how to write the code.


Sumit Kesarwani

Total Post:378

Points:2694
Posted on    March-31-2015 4:01 AM

Hi Jaya, 
            You can use a timer for this. On tick event of timer set line shape visibility to true and false and you can stat the timer on the button click like this:

namespace WindowsFormsApplication3
{
    public partial class Form1 : Form
    {
        Timer timer = new Timer();
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            timer.Start();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
           
            timer.Interval = 1000;
            timer.Enabled = true;
            timer.Tick += new System.EventHandler(timer_Tick);
        }

        private void timer_Tick(object sender, EventArgs e)
        {
            if (lineShape.Visible)
            {
                lineShape.Visible = false;
            }
            else
            {
                lineShape.Visible = true;
            }
        }
    }
}

Don't want to miss updates? Please click the below button!

Follow MindStick