Jump to content

if progress 100% then do something

WillLTT

im starting a new one based on the other one is getting old and was poorly explained. heres my code, im using c# .net in visual studio 2019 community

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ZFX_News
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            timer1.Start();
            
        }

        private void Timer1_Tick(object sender, EventArgs e)
        {
            progressBar1.Increment(1);

        }

        private void ProgressBar1_Click(object sender, EventArgs e)
        {

        }
    }
}

i want progressbar1 when its at 100% then 

open form 2 i only missing the code for progressbar1 i might be missing a using.

but i cannot find ANY good guides on this as every are old or not working resulting in toons of errors!

Link to comment
Share on other sites

Link to post
Share on other sites

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ZFX_News
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            timer1.Start();
            
        }

        private void Timer1_Tick(object sender, EventArgs e)
        {
            progressBar1.Increment(1);
            //try something like this:
            //check if the value of your progress bar is the same as the maximum
            if(progressBar1.Value == progressBar1.Maximum){
                //stop timer because you wont need it anymore	
                timer1.Stop();
              	//create and show new form
                Form2 frm2 = new Form2();
              	frm2.Show();
            }

        }

		//This event is fired if the Progress Bar is clicked, I don't think this is what you wanted
        private void ProgressBar1_Click(object sender, EventArgs e)
        {

        }
    }
}

I think this is the solution to your problem.

But I'm pretty sure that it was already answered in your last post.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×