0

I have a form which has a picturebox and after clicking on a button another form will appear with a picture box containing the exact same picture. I use this line of code:

Image1.Image = vImage.Image

The thing is after I do this i need to hide the form and show it again to be able to see the changes. I cause me a blink for user which I want to avoid or do an equivalent of hiding and showing a form. How is it possible, the code looks like this:

Public Sub UpdatePhoto(ByVal FullName As String, ByVal vImage As System.Windows.Forms.PictureBox)
timAnimate.Enabled = False
Me.Text = FullName
Image1.Image = vImage.Image
Me.Refresh()
Me.Hide()
Me.Show()
Image1.Visible = True
Call ShowTheWindow()

End Sub

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Faulty Orc
  • 955
  • 4
  • 13
  • 24
  • 2
    Sometimes it takes a while. Also you shouldn't post multiple questions that are the same( http://stackoverflow.com/questions/5117371/how-to-paint-our-changes-in-runtime-before-its-being-viewe-by-user and http://stackoverflow.com/questions/5117686/repainting-the-controls-without-flicker) – Tony Abrams Feb 25 '11 at 15:35
  • @TonyAbrams And you can add http://stackoverflow.com/questions/5116556/a-strange-minor-problem-in-moving-a-picture-from-a-box-to-another to the list... – Koen Feb 26 '11 at 15:29

1 Answers1

0

I'm not quite following why you need to hide and show the form. Are you just trying to get the form to refresh? If so, just call:

Application.DoEvents()

or else you can try invalidating your control:

Image1.Invalidate()

That should cause your form to update. You shouldn't need to hide and show again. If this isn't your issue, let me know in more detail what your problem is.

Davido
  • 2,913
  • 24
  • 38