multiplos lineshape RRS feed

  • Pergunta

  • Estou tentando criar multiplos lineshape de forma dinamica

       Dim clicado As Boolean = False
        Dim line As LineShape()
        Dim canvas As New ShapeContainer
        ' Dim form As New Form1
        Dim lbl As New Label
        Dim contador As Integer = -1
        Private Sub UserControl1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        End Sub
        Private Sub UserControl1_MouseDown(sender As Object, e As MouseEventArgs) Handles Me.MouseDown
            clicado = True
            If desenhalinha = True Then
                canvas.Parent = Me
                contador = contador + 1
                line(contador) = New LineShape()
                line(contador).Parent = canvas
                line(contador).BorderWidth = 3
                line(contador).StartPoint = New System.Drawing.Point(e.X, e.Y)
                line(contador).EndPoint = New System.Drawing.Point(e.X + 1, e.Y + 1)
            End If
        End Sub
    Mas na linha line(contador) = New LineShape()  esta dando o erro
    System.NullReferenceException was unhandled   Message=Object reference not set to an instance of an object.

    domingo, 20 de julho de 2014 03:59