This is about how to make a progress bar in Visual Studio.
Instructions:
- Open a new project and select Windows Forms Application
- Name your project progress Bar
- Drag and drop a progress bar on to your form
- Drag and drop a button on your form
- Drag and drop a timer
- The timer will appear on the bottom instead of on your form, so you are ok.
- Double click your button and enter the code you see below
- Double click your timer and enter the code
- Set interval on timer to 1000. It's kind of slow. To make it faster set it to 1.
- Copy the code below to to make it work
- Change the design to make it your own and play around with the controls to have a little fun
Good luck!
Here is the source code:
How to Make a Progress Bar and Button
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 progressBar
{
public partial class Progressbar : Form
{
public Progressbar()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
this.timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
this.progressBar1.Increment(1);
}
private void label1_Click(object sender, EventArgs e)
{
}
}
}
No comments:
Post a Comment