BigSprout,
Graphics is indeed an interesting topic.
As you've got it, the sub will only draw a rectangle on Me - being the form on which the sub is located. If you want to draw a rectangle on another form then add an extra parameter to specify the target form:
You can then call it from any form like this:
Graphics is indeed an interesting topic.
As you've got it, the sub will only draw a rectangle on Me - being the form on which the sub is located. If you want to draw a rectangle on another form then add an extra parameter to specify the target form:
Code:
[COLOR="Gray"]Sub AddRectangle([COLOR="Black"]ByVal TheForm As Form,[/COLOR] ByVal Lt As Integer, ByVal Tp As Integer, ByVal Wd As Integer, ByVal Ht As Integer)
'Add rectangles to the Web Page Form for the Price/Volume charts
Dim myBrush As New System.Drawing.SolidBrush(System.Drawing.Color.Red)
Dim myPen As New System.Drawing.Pen(System.Drawing.Color.Black)
Dim formGraphics As System.Drawing.Graphics
formGraphics = [COLOR="Black"]TheForm[/COLOR].CreateGraphics()
formGraphics.DrawRectangle(myPen, New Rectangle(Lt, Tp, Wd, Ht))
formGraphics.FillRectangle(myBrush, New Rectangle(Lt, Tp, Wd, Ht))
myPen.Dispose()
myBrush.Dispose()
formGraphics.Dispose()
End Sub[/COLOR]
AddRectangle(Me, 20, 10, 200, 300)
or perhaps:AddRectangle(Form2, 20, 10, 200, 300)


), I added this on Form2:
Comment