ProgressBar and Timer Control For explaining Progressbar control we have link it with event so that the value of progress bar can increase, so here i have chosen timer control. And the the value of progressbar control is increment with timer control tick event.
Progress bar control is used to hide the backend process so that user can aware of time consumed by back process of that application.
Code for Timer Control Tick Event-
private void timer1_Tick(object sender, EventArgs e)
{
progressBar1.Visible = true;
progressBar1.Value = progressBar1.Value + 5;
label3.Visible = true;
label3.Text = "Please Wait While we are checking Authentication...";
if (progressBar1.Value == progressBar1.Maximum)
{
if ((textBox1.Text == "r4r") && (textBox2.Text == "r4r"))
{
timer1.Enabled = false;
progressBar1.Visible = false;
label3.Text = "Welcome!! you are Authorised User.";
progressBar1.Enabled = false;
progressBar1.Value = 0;
groupBox1.Visible = false;
}
else
{
progressBar1.Enabled = false;
timer1.Enabled = false;
progressBar1.Visible = false;
progressBar1.Value = 0;
label3.Text = "Sorry!! Username or Password is Wrong.";
}
} |
Make Progressbar Control Visible Property "false".
Make timer enabled property true on "OK" button click.
private void button1_Click(object sender, EventArgs e)
{
timer1.Enabled = true;
} |
|
C# create progress bar imitating Timer control
ReplyDelete