Setting Reference to a form

  • Thread starter Thread starter Ron Dahl
  • Start date Start date
R

Ron Dahl

I can use either of the following two statements to draw a line:
Dim MyGDISurface As Graphics = Me.FieldMap.CreateGraphics

or I can use

Dim MyGDISurface As Graphics = FieldMap.CreateGraphics

What I'm trying (and failing) to do is have:

dim MyForm as new frmMain

Dim MyGDISurface As Graphics = frmMain.FieldMap.CreateGraphics

I don't get any error messages; it just doesn't seem to do anything.

I'm getting an unwieldy amount of code in frmMain, and I'd like to move some
of it to a module, and this was as far as I got.



The first two other lines in the procedure are:

Dim mybrush As New SolidBrush(Color.Red)

Dim ApplicatorPen As New Pen(mybrush, DisplaySwathWidth

and the last line is:

MyGDISurface.DrawLine(ApplicatorPen, 10, 10, 100, 10)

Thanks in advance for any help.

Ron Dahl
 
Hi,

Looking at your code you are creating a new frmMain and drawing on
that. You need to pass a reference to the frmmain that is open.

Ken
 
Back
Top