Thursday, 12 April 2012

How to Blinking the Text in Windows Form Applications

1.  Open the Visual Studio 2010-->File -->New-->Project-->Select Windows Form Application         -->ClickOK

2. From the Tool Box Take one Label And one Timer Control.

3. Change the Timer and Label Names.

4. Then Write the Below Code in Form1.CS  File

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication4
{

    public partial class Form1 : Form
    {
      
        private const int _blinkFrequency = 250;

        private const int _maxNumberOfBlinks = 1000;

        private int _blinkCount = 0;
        public Form1()
        {
            InitializeComponent();

            timer1.Interval = _blinkFrequency; //optional: set in design code
            label1.Text = "Welcome";
           
            timer1.Start();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
           
            this.label1.Visible = !this.label1.Visible;

            _blinkCount++;
         

            if (_blinkCount == _maxNumberOfBlinks * 2)
            {

                timer1.Stop();

                label1.Visible = true;

              

            }
        }

      
    }
}



5. After The Writing Code We Can Get output like This Below:





No comments:

Post a Comment