Click here to Skip to main content
15,888,521 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i need like
jun 12 2012 08:10 01 (here 01 should increase tat is seconds timing)
Posted

hi,
add a label and a button on your Form then on button_click write the following code
C#
private void btnStart_Click(object sender, EventArgs e)
       {
             Timer timer = new Timer();
           timer.Start();
           timer.Interval = 1;
           timer.Tick += new EventHandler(timer_Tick);
       }

C#
void timer_Tick(object sender, EventArgs e)
       {
           label1.Text = DateTime.Now.ToString("MM dd yyyy hh:mm:ss.fff");
           Update();
       }
 
Share this answer
 
Comments
Member 9113768 13-Jun-12 6:13am    
text1.text=timer.tick.tostring()
is this correct i want to display in textbox
tanweer 13-Jun-12 7:09am    
just replace the label name to your TextBox as
TextBox1.Text = DateTime.Now.ToString("MM dd yyyy hh:mm:ss.fff");

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900