PJRoyle
Member
I have a form which has a PictureBox (pbMap) containing an image, and a grid of data to the side. The image has been painted using this code:
Private mypic As System.Drawing.Bitmap
Private g As Graphics
mypic = New System.Drawing.Bitmap(strDataDir & "\" & strMapName)
g = pbMap.CreateGraphics
g.DrawImage(mypic, New Rectangle(0, 0, 640, 480))
Plus some other bits of drawing - which is why I'm not just assigning the image to the PictureBox.
As soon as I try to change the data in the grid (by keying into it) the picture disappears. I have a "Refresh picture" button, but I don't want users to have to keep pressing that. I have tried using both the KeyPress and KeyDown to trigger a redraw, but they don't work. The code is executed, but I don't see the image. Strangely, this only happens on the first attempt to modify the grid - after I lose the image once, and refresh it by the button, it stays there!
Please, has ANYONE got an answer to this? This is driving me daft!
Peter Royle
Private mypic As System.Drawing.Bitmap
Private g As Graphics
mypic = New System.Drawing.Bitmap(strDataDir & "\" & strMapName)
g = pbMap.CreateGraphics
g.DrawImage(mypic, New Rectangle(0, 0, 640, 480))
Plus some other bits of drawing - which is why I'm not just assigning the image to the PictureBox.
As soon as I try to change the data in the grid (by keying into it) the picture disappears. I have a "Refresh picture" button, but I don't want users to have to keep pressing that. I have tried using both the KeyPress and KeyDown to trigger a redraw, but they don't work. The code is executed, but I don't see the image. Strangely, this only happens on the first attempt to modify the grid - after I lose the image once, and refresh it by the button, it stays there!
Please, has ANYONE got an answer to this? This is driving me daft!
Peter Royle