In this Blog, we will see how to use ProgressBar control in a Windows Forms using Visual Studio 2005. We will also use Timer & BackgroundWorker in a forms.
![]()
ProgressBar : Displays a bar that fills to indicate to the user the progress of an operation.
![]()
Timer : Component that raises an event at user defined intervals.
![]()
BackgroundWorker : Executes an operation in a separate thread.
Here, we will use these controls for Windows application at Login Authentication operation.
Let's Start to Windows Application.
Drag ProgressBar, Timer & Backgroundworker to windows form,
Write code to btnLogin
if
(txtLogin.Text == "ADMIN" && txtPass.Text ==
"PASS")
{
timer1.Enabled =
true;
timer1_Tick(sender, e);
panel2.Enabled =
true;
panel3.Enabled =
true;
lblTime.Text =
Convert.ToString(DateTime.Now.TimeOfDay).Substring(0,
8);
lblDate.Text =
Convert.ToString(DateTime.Now.Date).Substring(0,
11);
}
else
{
MessageBox.Show("Please Enter Right password
and username");
}
Write code to BackgroundWorker
private
void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
System.ComponentModel.BackgroundWorker
worker = (System.ComponentModel.BackgroundWorker)sender;
backgroundWorker1.RunWorkerAsync();
}
Write code to Timer
if
(progressBar1.Value < progressBar1.Maximum)
{
progressBar1.Value =
progressBar1.Value + 50;
}
else
{
timer1.Enabled =
false;
lblTime.Enabled =
true;
lblTime.Visible =
true;
txtLogin.Enabled =
false;
txtPass.Enabled =
false;
progressBar1.Enabled =
false;
progressBar1.Visible =
false;
btnLogin.Enabled =
false;
}
For full code, download files.
User ID : ADMIN
Password :PASS

AFTER SUCCESSFULLY LOGIN AUTHENTICATION…


Join the conversation! Your thoughts help the community grow.