I added a progress bar awhile ago and it seemed to be working fine, but then I started a new project and now the progress bar isnt doing anything when my button is clicked. I have a button and a timer so I dont know the reason as to why they arent working.
private void button2_Click(object sender, EventArgs e)
{
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
//MINIMUM IS ALREADY DEFINED AS 0
//SET MAXIMUM IN THE PROPERTIES BAR
progressBar1.Value += 3;
if (progressBar1.Value == 99)
{
timer1.Stop();
MessageBox.Show("Complete");
progressBar1.Value = 0;
this.Hide();
Form2 newform = new Form2();
newform.Show();
}
}
Loading
Satyapriya NayakPosted Dec 31, 2011, 2:09 AM
Right click on timer1 control - Click Properties - Go to the Events tab - Notice in Tick texbox it is blank.Paste timer1_Tick there.
Run the application.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void pictureBox3_Click(object sender, EventArgs e)
{
}
private void progressBar1_Click(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
timer1.Start();
//this.Hide();
//Form2 newform = new Form2();
//newform.Show();
}
private void timer1_Tick(object sender, EventArgs e)
{
//MINIMUM IS ALREADY DEFINED AS 0
//SET MAXIMUM IN THE PROPERTIES BAR
progressBar1.Value += 3;
if (progressBar1.Value == 99)
{
timer1.Stop();
MessageBox.Show("Complete");
progressBar1.Value = 0;
}
}
}
}
Thanks
Caleb DunnPosted Dec 31, 2011, 4:13 AM
Satyapriya NayakPosted Dec 31, 2011, 2:01 AM
Try this...
Remove those lines from Form1.Designer.cs file
this.pictureBox6.Image = global::WindowsFormsApplication1.Properties.Resources.coollogo_com_14541736;
this.pictureBox4.Image = global::WindowsFormsApplication1.Properties.Resources.coollogo_com_14541736;
this.pictureBox3.Image = global::WindowsFormsApplication1.Properties.Resources.Animated_Gif_Science__15_;
this.pictureBox1.Image = global::WindowsFormsApplication1.Properties.Resources.coollogo_com_14741289;
Remove those code first Form1.cs file
private void timer1_Tick(object sender, EventArgs e)
{
//MINIMUM IS ALREADY DEFINED AS 0
//SET MAXIMUM IN THE PROPERTIES BAR
progressBar1.Value += 3;
if (progressBar1.Value == 99)
{
timer1.Stop();
MessageBox.Show("Complete");
progressBar1.Value = 0;
}
}
Then go to the Form1.cs[Design] page .Here in the timer1 control double click it and paste the below code as
private void timer1_Tick(object sender, EventArgs e)
{
//MINIMUM IS ALREADY DEFINED AS 0
//SET MAXIMUM IN THE PROPERTIES BAR
progressBar1.Value += 3;
if (progressBar1.Value == 99)
{
timer1.Stop();
MessageBox.Show("Complete");
progressBar1.Value = 0;
}
}
Thanks
Caleb DunnPosted Dec 31, 2011, 1:17 AM
http://www.mediafire.com/download.php?4igyiz5tt1s63o1
Satyapriya NayakPosted Dec 31, 2011, 12:52 AM
Caleb DunnPosted Dec 31, 2011, 12:40 AM
Satyapriya NayakPosted Dec 31, 2011, 12:19 AM
No error in the code.Its working fine here.What error you are getting.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
progressBar1.Value += 3;
if (progressBar1.Value == 99)
{
timer1.Stop();
MessageBox.Show("Complete");
progressBar1.Value = 0;
this.Hide();
Form2 newform = new Form2();
newform.Show();
}
}
}
}
Thanks