I have form with a picturebox on it. I have a global bitmap variable. If I draw something on the bitmap, like this:
It works fine. However, if I run the same code from a module and change the last line to frmRX.pbRX1.Image = GbmRX it doesn't work. Or rather, the rectangle is drawn but is not visible until I force the form to redraw; dragging it off the screen and then back on again, for example. Adding something like frmRX.pbRx1.Invalidate() doesn't help. I don't seem able to force the picturebox to redraw from the module. I tried adding a sub in frmRX that just assigns the bitmap to the picturebox, then calling that from the module and that doesn't work either. Where am I going wrong?
Code:
' GbmRX is a global bitmap variable
' pbRx1 is a picturebox control on frmRX
Dim g As Graphics = Graphics.FromImage(GbmRX)
g.FillRectangle(New SolidBrush(Color.Red), New Rectangle(0, 0, 640, 480))
pbRX1.Image = GbmRX