Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27513

VS 2010 [RESOLVED] Can't update picturebox image from a module

$
0
0
I have form with a picturebox on it. I have a global bitmap variable. If I draw something on the bitmap, like this:
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

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?

Viewing all articles
Browse latest Browse all 27513

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>