C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Winforms Controls »

Using Progress Bar control in Login Form


Posted Date: 20 Jul 2009    Resource Type: Code Snippets    Category: Winforms Controls
Author: Deepika HaridasMember Level: Diamond    
Rating: 1 out of 5Points: 12



Description :


Simple use of progress bar control which is being used in many places. I have made a sample for login form.















VB.Net

Public Class Form1


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim x As Integer
If TextBox1.Text = "deepika" And TextBox2.Text = "pass" Then
ProgressBar1.Visible = True
ProgressBar1.Minimum = 1
ProgressBar1.Maximum = 100000
ProgressBar1.Value = 1
ProgressBar1.Step = 1
For x = 1 To 100000
ProgressBar1.PerformStep()
Next x
Me.Hide()
Form2.Show()
Else : MsgBox("Wrong User ID or Password! Try Again!")
TextBox1.Text = ""
TextBox2.Text = ""
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
End Class

C#

private void button1_Click(object sender, EventArgs e)
{
int x = 0;
if (textBox1.Text == "deepika" & textBox2.Text == "pass")
{
progressBar1.Visible = true;
progressBar1.Minimum = 1;
progressBar1.Maximum = 100000;
progressBar1.Value = 1;
progressBar1.Step = 1;
for (x = 1; x <= 100000; x++)
{
progressBar1.PerformStep();
}
this.Hide();
frm.Show();
}
else
{
MessageBox.Show("Wrong User ID or Password! Try Again!");
textBox1.Text = "";
textBox2.Text = "";
}
}


For more details, visit http://angeldeeps.blogspot.com/2009/06/progress-bar-in-login-form.html



Responses

Author: Abhisek Panda    20 Jul 2009Member Level: Gold   Points : 0
Good post. I really need it.


Regards
Abhisek Panda


Author: Viral Shah    21 Jul 2009Member Level: Bronze   Points : 1
hi

Nice post. really useful.

But can we show percantage like 10% , 20% just like in normal
our installation software along with?


Author: Deepika Haridas    21 Jul 2009Member Level: Diamond   Points : 1
Hi Viral,

Thanks for the suggestion. Will try to post that soon.

--
Thanks & Regards,
Deepika
Editor


Author: Viral Shah    21 Jul 2009Member Level: Bronze   Points : 1
hii

I m very surprised to see your quickest response. Great person you are.

Actually , i m only hv 3 months exp ,so i want to learn much thing from this sites.

Thanks,
Viral Shah


Author: Deepika Haridas    27 Jul 2009Member Level: Diamond   Points : 4
Hi,

As per one member's question I am posting another solution for the same post.

To show percentage along with the progress bar just need to add the following code within the for loop.


progressBar1.Refresh();
int percent = (int)(((double)progressBar1.Value / (double)progressBar1.Maximum) * 100);
progressBar1.CreateGraphics().DrawString(percent.ToString() + "%", new Font("Arial", (float)10.25, FontStyle.Regular), Brushes.Black, new PointF(progressBar1.Width / 2 - 10, progressBar1.Height / 2 - 7));


You can change width and height based on your requirement.

--
Thanks & Regards,
Deepika
Editor


Author: Viral Shah    29 Jul 2009Member Level: Bronze   Points : 0
Thank you Ma'm.




Author: Abhay    14 Aug 2009Member Level: Diamond   Points : 1
Hi dEEPIKA,

good one .

keep it up.

contribute more.

Thanks and Regards
Abhay


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Using Progress Bar control in Login Form  .  Progress Bar  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Opening a Website from Winforms
Previous Resource: Restrict .Net Window Forms resizing
Return to Discussion Resource Index
Post New Resource
Category: Winforms Controls


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use