TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
vinoth kumar
NA
23
48.7k
Countdown timer all button textbox not visible
Oct 31 2012 3:43 AM
This is my coding but countdown timer is not running and all textbox and labels are not visible..what is the error of this coding..
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Timers;
namespace timer1
{
public partial class Form1 : Form
{
public int seconds;
public int minutes;
public int hours;
public bool paused;
public Form1()
{
}
private void button1_Click(object sender, EventArgs e)
{
{
if (paused != true)
{
if ((textBox1.Text != "") && (textBox2.Text != "") && (textBox3.Text != ""))
{
timer1.Enabled = true;
button1.Enabled = true;
button2.Enabled = false;
button3.Enabled = true;
textBox1.Enabled = false;
textBox2.Enabled = false;
textBox3.Enabled = false;
textBox4.Enabled = false;
try
{
minutes = System.Convert.ToInt32(textBox2.Text);
seconds = System.Convert.ToInt32(textBox3.Text);
hours = System.Convert.ToInt32(textBox1.Text);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
else
{
MessageBox.Show("Incomplete settings!");
}
}
else
{
timer1.Enabled = true;
paused = false;
button2.Enabled = false;
button1.Enabled = true;
}
}
}
private void button2_Click(object sender, EventArgs e)
{
timer1.Enabled = false;
paused = true;
button1.Enabled = false;
button2.Enabled = true;
}
private void button3_Click(object sender, EventArgs e)
{
// Stop the timer.
paused = false;
timer1.Enabled = false;
button1.Enabled = false;
button3.Enabled = false;
button2.Enabled = true;
textBox4.Clear();
textBox3.Clear();
textBox2.Clear();
textBox1.Clear();
textBox1.Enabled = true;
textBox4.Enabled = true;
textBox3.Enabled = true;
textBox2.Enabled = true;
textBox1.Enabled = true;
label1.Text = "00";
label2.Text = "00";
label3.Text = "00";
}
private void timer1_Tick(object sender, EventArgs e)
{
if ((minutes == 0) && (hours == 0) && (seconds == 0))
{
// If the time is over, clear all settings and fields.
// Also, show the message, notifying that the time is over.
timer1.Enabled = false;
MessageBox.Show(textBox4.Text);
button1.Enabled = false;
button3.Enabled = false;
button2.Enabled = true;
textBox4.Clear();
textBox3.Clear();
textBox2.Clear();
textBox1.Enabled = true;
textBox4.Enabled = true;
textBox3.Enabled = true;
textBox2.Enabled = true;
textBox1.Enabled = true;
label1.Text = "00";
label2.Text = "00";
label3.Text = "00";
}
else
{
// Else continue counting.
if (seconds < 1)
{
seconds = 59;
if (minutes == 0)
{
minutes = 59;
if (hours != 0)
hours -= 1;
}
else
{
minutes -= 1;
}
}
else
seconds -= 1;
// Display the current values of hours, minutes and seconds in
// the corresponding fields.
label1.Text = hours.ToString();
label2.Text = minutes.ToString();
label3.Text = seconds.ToString();
}
}
}
}
Reply
Answers (
1
)
Dynamically GridView code behind
stackoverflowexception