Welcome back coders, today is Tuesday and it's a beautiful summer day outside to do some programming indoors. Today we are going to be learning on how to do a basic CSharp (C#) ProgressBar.
For this tutorial you are going to need,
- Two Buttons (Start & Stop)
- Timer
- ProgressBar
Now to the fun part, the code! You can simply skip the video below, or watch it to get a step-step guide on how to do things (plus I explain things more in detail) or simply grab the code below the video.
- 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 CSharp___Ep_2_Basic_Intro_to_Progessbar
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- //Start the Timer
- timer1.Start();
- }
- private void button2_Click(object sender, EventArgs e)
- {
- //Stop the Timer
- timer1.Stop();
- }
- private void timer1_Tick(object sender, EventArgs e)
- {
- //Get the progressbar moving, by 1 increment everytime Timer1 loops (# of intervals)
- progressBar1.Increment(+1);
- //If ProgressBar 1, is 100% done loading
- if(progressBar1.Value == 100)
- {
- //Then this will take place ------------------------------
- timer1.Stop();
- MessageBox.Show("Coder Revolt, is 100% Done");
- progressBar1.Value = 0;
- }
- }
- }
- }
0 comments :
Post a Comment