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
- Button1_Click(ByVal sender as System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- ‘ Declarations and other code
- ' Progress Bar Initialization
- uiFileCreationProgressBar.Maximum = uiDistrictsSelectedListBox.Items.Count * 2
- uiFileCreationProgressBar.Value = dCount
- uiFileCreationLabel.Text = uiFileCreationProgressBar.Value '"Starting File Creation"
- Me.UseWaitCursor = True
- ' For-loop to Create seperate Query files
- For dCount = 0 To uiDSelectedListBox.Items.Count - 1
- ' Set file name
- If (uiUploadTypeComboBox.SelectedIndex = 1) Then
- fileName = "Custom - " _
- & Convert.ToString(uiDSelectedListBox.Items.Item(dCount))
- Else
- fileName = Convert.ToString(uiDSelectedListBox.Items.Item(dCount))
- End If
- File1Create(fileLocation, fileName, dCount, connstring)
- uiFileCreationProgressBar.Value = dCount * 2 + 1
- uiFileCreationLabel.Text = Convert.ToInt32((((dCount * 2) + 1) / (uiDSelectedListBox.Items.Count * 2)) * 100) & "% Complete"
- File2Create (fileLocation, fileName, dCount, connstring)
- uiFileCreationProgressBar.Value = dCount * 2 + 2
- uiFileCreationLabel.Text = Convert.ToInt32((((dCount * 2) + 2) / (uiDSelectedListBox.Items.Count * 2)) * 100) & "% Complete"
- Next
- ' Remove wait cursor
- uiFileCreationLabel.Text = uiFileCreationProgressBar.Value '"100% Completed"
- Me.UseWaitCursor = False
- MsgBox("File(s) Created Succesfully.", 0, "File Creation Status")
- uiFileCreationLabel.Text = uiFileCreationProgressBar.Value '"Press View Report to Begin."
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.