Help I broke my statusstrip..?  
Author Message
MartijnP





PostPosted: Visual Basic Express Edition, Help I broke my statusstrip..? Top

I have a statusstrip1 in my app. There's a couple of buttons. At each ButtonClick.Event I change the StatusLabel1.Text a couple of times during the process. With this I'm using a progressbar which is updated by a performstep().

Now, after pressing the first button, everything runs smooth.. StatusLabel1.Text gets updated nicely and the Progressbar does its thing. However, after pressing the second button (generate) my label isnt updated at all and i see 3 instances of my progressbar... The weird thing is when I add a messagebox to the code the statuslabel does update and the progressbar shows 1 instance.. Can it be something in the code I tried it with both VB Express and VS2005, same result.. Thanks

Private Sub Prepare_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Prepare.Click

'Set Status in StatusStrip

Status.Text = "Working"

Status.Image = CreUser.My.Resources.Resources.mintcnuir

'Make Progressbar visible

PBar1.Visible = True

PBar1.Minimum = 1

PBar1.Maximum = 10

PBar1.Value = 1

PBar1.Step = 1

...

'MY CODE

'Progressbar update

PBar1.PerformStep()

'MY CODE

...

PBar1.Visible = False

PBar1.Enabled = False

'Set Status in StatusStrip

Status.Text = "Done"

Status.Image = CreUser.My.Resources.Resources.mintcnuig

End Sub

Private Sub Generate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Generate.Click

'Set Status in StatusStrip

Status.Text = "Generating"

Status.Image = CreUser.My.Resources.Resources.mintcnuir

'MessageBox.Show("...")

'Initiate external VBScript

'Dim retval As Double

'retval = Shell("schtasks /run /tn CreateUser /s....", AppWinStyle.Hide, False, -1)

'Set Status in StatusStrip

Status.Text = "Creating User Account"

Status.Image = CreUser.My.Resources.Resources.mintcnuib

'Wait until main network homefolder exists

Do Until CheckDir = 6

Call CopyHomeFolder()

Thread.Sleep(5000)

Loop

'Set Status in StatusStrip

Status.Text = "Check Homefolders"

Status.Image = CreUser.My.Resources.Resources.mintcnuir

Call CheckHomeFolder()

'Set Status in StatusStrip

Status.Text = "Create Logfile"

'Export to log

Call ExportToLog()

'Set Status in StatusStrip

Status.Text = "Cleanup"

'Reset Form

Call FormReset()

'ButtonReset

Call ButtonReset()

'Initieer Inputstart

Call Inputstart()

'Set Status in StatusStrip

Status.Text = "Done"

Status.Image = CreUser.My.Resources.Resources.mintcnuig

Quit.Enabled = True

End Sub



Visual Studio Express Editions31  
 
 
nobugz





PostPosted: Visual Basic Express Edition, Help I broke my statusstrip..? Top

You're not giving the controls a chance to repaint themselves. Fix it by calling DoEvents inside your code or using the BackgroundWorker class. DoEvents is frowned upon...