espfutbol98
New Member
- Messages
- 200
- Reaction score
- 2
- Points
- 0
Hello, I have a Forms program in Visual C# and there is an image, four text labels, and one progress bar. Three of the labels are supposed to be visible always while the remaining text label and progress bar are supposed to disappear after a for loop from 0 reaches 100 with progressBar1.Value++ and System.Threading.Thread.Sleep(50).
At first I used the Load event handler but the progress bar would complete its task before the entire window opened in the first place. Next I tried using the Show handler but the current problem is the labels and image boxes load but no values are added. The images below will better explain but what I'm wondering is do I have to use multi-threaded methods and if so, how would I do that in this particular case?
Should appear as:
However in the begining:
And finally after for loop ends:
At first I used the Load event handler but the progress bar would complete its task before the entire window opened in the first place. Next I tried using the Show handler but the current problem is the labels and image boxes load but no values are added. The images below will better explain but what I'm wondering is do I have to use multi-threaded methods and if so, how would I do that in this particular case?
Code:
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 subjectSystem
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.Shown += new System.EventHandler(this.Form1_Show_1);
}
private void Form1_Show_1(object sender, EventArgs e)
{
label4.Visible = true;
for (int i = 0; i < 100; i++)
{
progressBar1.Value++;
System.Threading.Thread.Sleep(50);
}
System.Threading.Thread.Sleep(500);
label4.Visible = false;
progressBar1.Visible = false;
}
}
}
Should appear as:
However in the begining:
And finally after for loop ends: