rufus Posted July 14, 2003 Posted July 14, 2003 I written a code in button click event as Dim grph As System.Drawing.Graphics Try Dim pen As Pen pen = New Pen(Color:=Color.Blue, Width:=1) grph.DrawLine(pen, 10, 10, 10, 10) Catch ex As Exception MsgBox(ex.ToString, MsgBoxStyle.OKCancel) End Try when Iam running,its giving error as Object reference not set to an instance of object. at grph.DrawLine(pen, 10, 10, 10, 10) can any one can help. Quote Rufus
*Experts* Volte Posted July 14, 2003 *Experts* Posted July 14, 2003 You need to set grph to an instance of a Graphics object. For example;Dim grph As System.Drawing.Graphics = Me.CreateGraphicswould use the graphics object of the form. Quote
rufus Posted July 15, 2003 Author Posted July 15, 2003 The error is gone, but Iam not able to see the line, I have changed the width and height and nothing happened. Quote Rufus
*Experts* Volte Posted July 15, 2003 *Experts* Posted July 15, 2003 It doesn't surprise me that you can't see the line, since the start point and end point are at the same point (10, 10). Try changing the coordinates. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.