Refreshing Canvas Paint Event


I am trying to change the image displayed on a canvas during runtime. The image names are stored in a sqlite database.

In View1 the image is shown.
In View 2 is where I can change the name of the image.

So I go from View1 to View2 where I change the name of the image. When I go back to View1, I want the image to change to the new picture.

In the Paint Event of the Canvas, I have this code:

[code] Select Case txtScreen.Text

Case “Image1”

g.DrawImage(Picture1, 0, 0)

Case “Image2”

g.DrawImage(Picture2,  0, 0)

End Select[/code]

How can I refresh the canvas so it fires the paint event when I get back to View1

I don’t see and Refresh. Any help would be appreciated.


Thanks Norman. That did the trick. I appreciate the help.

Usually when you think “Oh I need to force a refresh” you don’t and can use Invalidate which lets the app redraw whatever needs to be redrawn on the next iteration of the main event loop

I put the code in the Activate event and it worked like a champ. Thanks again. :slight_smile: