473,387 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Statusstrip and StatusLabel

Background:
The Program runs a query on a SQL Database, then it takes the gathered information and outputs it into an excel document and saves it to a specified location.

Problem:
Originally I was using a Label and ProgressBar Located in the form itself but for the sake of appearance I decided it would look better to create a StatusStrip. I relocated the uiFileCreationLabel and uiFileCreationProgressBar to the Status strip as a StatusLabel and ProgressBar. After doing so the ProgressBar worked flawlessly and looked awesome, but the StatusLabel did not follow the ProgressBar's example of good behavior. The code is run inside a Button_Click and the label is supposed to update with the current Percentage of the Overall File Creation. The Only time the label actually updates its text, despite the fact that the code says it should update 4 times for 1 set of files or 6 times for 2 sets of files, is the last time of the updates.

Question:
How can I make the StatusLabel Text update itself? Do I need to call a separate function outside of the Button_Click to update the text specifically?


Expand|Select|Wrap|Line Numbers
  1. Button1_Click(ByVal sender as System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2. ‘ Declarations and other code
  3.  
  4. ' Progress Bar Initialization
  5. uiFileCreationProgressBar.Maximum = uiDistrictsSelectedListBox.Items.Count * 2
  6.             uiFileCreationProgressBar.Value = dCount
  7.             uiFileCreationLabel.Text = uiFileCreationProgressBar.Value '"Starting File Creation"
  8.  
  9.             Me.UseWaitCursor = True
  10.  
  11.             ' For-loop to Create seperate Query files
  12.             For dCount = 0 To uiDSelectedListBox.Items.Count - 1
  13.                 ' Set file name
  14.                 If (uiUploadTypeComboBox.SelectedIndex = 1) Then
  15.                     fileName = "Custom - " _
  16.                     & Convert.ToString(uiDSelectedListBox.Items.Item(dCount))
  17.                 Else
  18.                     fileName = Convert.ToString(uiDSelectedListBox.Items.Item(dCount))
  19.                 End If
  20.  
  21.                 File1Create(fileLocation, fileName, dCount, connstring)
  22.                 uiFileCreationProgressBar.Value = dCount * 2 + 1
  23.                 uiFileCreationLabel.Text = Convert.ToInt32((((dCount * 2) + 1) / (uiDSelectedListBox.Items.Count * 2)) * 100) & "% Complete"
  24.                 File2Create (fileLocation, fileName, dCount, connstring)
  25.                 uiFileCreationProgressBar.Value = dCount * 2 + 2
  26.                 uiFileCreationLabel.Text = Convert.ToInt32((((dCount * 2) + 2) / (uiDSelectedListBox.Items.Count * 2)) * 100) & "% Complete"
  27.             Next
  28.  
  29.             ' Remove wait cursor
  30.             uiFileCreationLabel.Text = uiFileCreationProgressBar.Value '"100% Completed"
  31.             Me.UseWaitCursor = False
  32.             MsgBox("File(s) Created Succesfully.", 0, "File Creation Status")
  33.             uiFileCreationLabel.Text = uiFileCreationProgressBar.Value '"Press View Report to Begin."
  34.  
  35.  

Comments:
Thank you for any help you have to offer me. If you need any more explanation to help or more code just let me know.
Oct 24 '07 #1
3 4457
Plater
7,872 Expert 4TB
Whenever you want a control to re-draw itself, use the .Update() function on it.

myStatusLAbel.Update() will force the UI to redraw itself.

I didn't look to closely at your code, but this works fairly often to solve that kind of problem.
Oct 24 '07 #2
I ended up figuring it out. I'm not sure if you can update the label itself but what i was able to do is tell the StatusStrip to .Refresh() and that refreshes the label and progress bar.

Thank you for your help though.
Oct 24 '07 #3
Plater
7,872 Expert 4TB
All controls have the .Update(), Refresh() is roughly the same thing though.
Oct 25 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Jim Hubbard | last post by:
When you add a StatusStrip to a WinForm and add a Progressbar to the StatusStrip, setting the Progressbar alignment to "Right" does not move the Progressbar to the right on the Statusbar. Is...
3
by: windsurfing_stew | last post by:
Hi, Winforms has the new StatusStrip control that replaces StatusBar in 1.1. I've looked high and low but can't seem to find how to get separators (|) in my status bar, eg Info1 | Info2 |...
2
by: robertino | last post by:
Hi all, (VS 2005 Pro, XP) I'm trying to place a statusstrip control on a window such that it acts like a statusstrip (!). Every time I try this, no matter what I do, I find that when I...
5
by: Marc | last post by:
Hello, I have a vb.net form that I've added a StatusStrip at the bottom. On that StatusStrip I've added a DropDownButton on which I've added a Menu containing 4 sub Items
0
by: Rich | last post by:
Hello, I just upgraded a vb2003 app to vb2005. The vb2003 app had/has a statusbar object - which contains panels and I can see the properties of the statusbar in the properties window in...
2
by: jcvoon | last post by:
Hi: I'm using VS2005, I've create a winform with the following controls: Add a ToolStripContainer Set it to dock to the form (Fill) Click in the top section. Add a menu strip Add a tool...
1
by: Carla Simeoni | last post by:
I added a StatusStrip "Sstrip1" to a Form "Form1". In the procedure private void Form1_Load(...) I added the following statement: Sstrip1.Text = "Text in my StatusStrip";
1
by: S. Viswanathan | last post by:
Hi! When mouse over on menuitem, the corresponding menuitem text should display in StatusStrip control. How to do this? Simillarly for when mouse over on toolstrip item, the corresponding...
10
by: hzgt9b | last post by:
Using VS2005 (.NET 2.0), VB.NET, I have a windows forms application. I have a StatusStrip containing a ToolStripStatusLabal and a ToolStripProgressBar. I want to force the status label to behave...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.