Showing/Hiding control

  • Thread starter Thread starter Simone Maynard
  • Start date Start date
S

Simone Maynard

Why doesn't this work?
I wanted to have a picture visible only during the execution of a function,
but this picture never gets visible. I replaced my event call with a call to
Thread.Sleep, still doesn't work.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
PictureBox1.Visible = True
System.Threading.Thread.Sleep(2000)
'RaiseEvent OnTest(Me, New EventArgs) 'commented this out
PictureBox1.Visible = False
End Sub

Please help! Thanks!
Simone
 
At a guess, you are trying to do this from the main thread in your
application (the one that also does message processing). When that's going
on, things like paint events aren't dispatched to the other controls, forms,
etc. in your application so they never appear. If you want to display the
picture while some long process goes on, you'll have to do the long process
from a thread and trigger the visibility before launching that long
thread....

Paul T.
 
put a ME.update or a Me.refresh right after you set the
picturebox to true and see if it comes up
 
I usually insert Application.DoEvents, but I guess Me.Update will work as
well.
 
Back
Top