Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to refresh PictureBox

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...

like image 505
unnamed Avatar asked Jan 27 '12 08:01

unnamed


People also ask

How to refresh PictureBox in c#?

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


2 Answers

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.

like image 188
Aulimaitar Avatar answered Sep 28 '22 06:09

Aulimaitar


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

like image 29
Smi Avatar answered Sep 28 '22 06:09

Smi