13

I've little question to ask.

Let's say I've written an ellipse on pictureBox, then clicked a button. I want pictureBox to refresh itself.

I've tried PictureBox.Invalidate(), but could'nt made it. My best regards...

unnamed
  • 840
  • 9
  • 26
  • 38
  • Just for clarification: you draw the ellipse on the picturebox control or on the picture you are showing in the picturebox? – Steve Jan 27 '12 at 08:28
  • @Steve, Could you explain the difference? – unnamed Jan 27 '12 at 08:30
  • Try to Hide(); and Show(); it will get Refreshed . – Rosmarine Popcorn Jan 27 '12 at 08:53
  • If you draw a ellipse on the picture (the thing you add to PictureBox.Image) you need to assign this picture again. If you draw something to the form where you placed the PictureBox on it should be enough to refresh / redraw the PictureBox – Steve Jan 27 '12 at 09:10

3 Answers3

20

Try the method PictureBox.Refresh() (inherited from Control).

Smi
  • 13,850
  • 9
  • 56
  • 64
2

There are a couple ways to update the PictureBox, and the method you use makes a difference if you have some lag. I had a program that drew typed characters in a PictureBox, and the keystroke processing was slow so when I typed fast it would lag.

If I pictureBox.Refresh(); after each keystroke, then that refreshes the picture immediately after the keystroke is processed, no matter what. This way, when I typed fast I could see the PictureBox trying to catch up with me as it drew each character.

If instead I pictureBox.Invalidate();, then that refreshes the picture too, but only when the system has some free time. This way, when I typed fast I saw nothing happening while the system tried to catch up, and then everything I'd typed suddenly appeared.

Usually Refresh is better, but here's an article that describes a couple situations where Invalidate is the better choice.

Aulimaitar
  • 119
  • 5
2

Have you tried PictureBox.Update(); ? Or try something like this http://msdn.microsoft.com/en-us/library/system.windows.forms.picturebox.image.aspx

JanOlMajti
  • 1,387
  • 4
  • 22
  • 34