Israel

Israel

  • 698
  • 1.3k
  • 219.8k

How can pass Progressbar with percentage to another Form

Feb 23 2019 5:54 PM
Hi,
I wrote these codeforactivate my Progressbar. Its works but itsdoesnt pass to another form (form2). How can do?
 
Thank you, 
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.ComponentModel;  
  4. using System.Data;  
  5. using System.Drawing;  
  6. using System.Linq;  
  7. using System.Text;  
  8. using System.Threading.Tasks;  
  9. using System.Windows.Forms;  
  10. namespace WindowsFormsApplication1  
  11. {  
  12. public partial class Form1 : Form  
  13. {  
  14. int progress = 0;  
  15. public Form1()  
  16. {  
  17. InitializeComponent();  
  18. }  
  19. private void timer1_Tick(object sender, EventArgs e)  
  20. {  
  21. this.progressBar1.Increment(1);  
  22. if(progressBar1.Value == progressBar1.Maximum)  
  23. {  
  24. this.timer1.Stop();  
  25. }  
  26. progress += 1;  
  27. if (progress >= 100)  
  28. {  
  29. timer1.Enabled = false;  
  30. timer1.Stop();  
  31. }  
  32. progressBar1.Value = progress;  
  33. percentTxt.Text = progress.ToString()+".00 %";  
  34. }  
  35. private void button1_Click(object sender, EventArgs e)  
  36. {  
  37. timer1.Enabled = true;  
  38. timer1.Interval = 50;  
  39. Form2 frm2 = new Form2();  
  40. frm2.ShowDialog();  
  41. }  
  42. }  
  43. } 

Answers (2)