Graphics on a Separate Form
Ø Project, Add Windows Form
Ø FormName.Show at start of graphics on the new form
Ø Prefix properties with name of the form; otherwise will defalt to Form1
Ø Prefix main form properties with Me
Ø Place items that you want to load before running program in the Form Load procedure
Public Class
Form1
Private XStart As Integer
Private YStart As Integer
Private XEnd As Integer
Private YEnd As Integer
Private Sub
Button1_Click(ByVal sender
As System.Object,
ByVal e As System.EventArgs)
Handles Button1.Click
Form2.Show()
'Get line parameters supplied by user
XStart = StartX.Text
YStart = StartY.Text
XEnd = EndX.Text
YEnd = EndY.Text
Dim G As
Graphics
G = Form2.CreateGraphics
Form2.Height = 400
Form2.Width = 400
Form2.Text = "Lines"
Dim pen As New Pen(Color.Black)
G.DrawLine(pen, XStart, YStart, XEnd, YEnd)
End Sub
Private Sub
Form1_Load(ByVal sender
As System.Object,
ByVal e As System.EventArgs)
Handles MyBase.Load
Me.Text =
"Start Form"
Me.BackColor = Color.AliceBlue
Me.ForeColor = Color.Blue
End Sub
End Class


Form1 at Run Time (After data input and before clicking Start)

Form2 at Run Time (After clicking start on Form1)
