Hi I want to make a c sharp win form application. in which there should be a counter which count 0 to 10 and then again start from 0 and when i press stop button it stop. the out put should be shown in the label.
Please Help Me
Thanks
Loading
ShankeyPosted Jan 7, 2011, 4:41 AM
Following is the code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace DemoTimer
{
public partial class Form1 : Form
{
public Int32 count=0;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
timer1.Interval = 100;
timer1.Start();
button2.Enabled = true;
button1.Enabled=false;
}
private void button2_Click(object sender, EventArgs e)
{
timer1.Stop();
button1.Enabled = true;
button2.Enabled = false;
}
private void timer1_Tick(object sender, EventArgs e)
{
count++;
if (count > 10)
{
count = 0;
}
label1.Text =Convert.ToString(count);
}
}
}
put following controls on the windows form
timer control
two button control
and a label