Real-Time Solutions


In this section i talk about real time solution for Programming in.net.

Blinking your label.

Every programmer want to make a application in nice looking.So today i'll teach simple method for designing
your heading or subheading  Label.
Firstly we must want to prepare our Windows form in Visual Studio.
Add a Windows Form


                                                         Add a Label in tool box

                                               
                                                                Add a Timer
                                                        Change Property in Timer.

then initializes a global variable like below
int flabel=0;

 In timer_tick Event Write below code


           if (flabel == 0)
            {
                label1.ForeColor = Color.Blue;
                flabel = 1;
            }
            else if(flabel==1)
            {
                label1.ForeColor = Color.Green;
                flabel = 0;
            }


Full Code Window Here

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 Label
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        int flabel = 0;//Intitialies Variable.

        private void timer1_Tick(object sender, EventArgs e)
        {
            if (flabel == 0)
            {
                label1.ForeColor = Color.Blue;
                flabel = 1;
            }
            else if(flabel==1)
            {
                label1.ForeColor = Color.Green;
                flabel = 0;
            }
        }
    }
}
 

 Check your Blinking Label.
Thank you.....

No comments:

Post a Comment