I'm working on a user defined control, with a simple label.
My control has this function:
Sub AddRow(ByVal Texto As String)
When I execute AddRow("Sample" ) I want that my control adds a label to
an array and sets the text to the latest label in the array.
This is what I've done:
Public Row(0) As String
Public List() As Label
Sub AddRow(ByVal Texto As String)
ReDim Preserve Row(UBound(Row) + 1)
Row(UBound(Row) ) = Texto
Dim NewLabel As New Label
NewLabel.Name = Texto
NewLabel.Size = New System.Drawing. Size(39, 13)
NewLabel.TabInd ex = 0
NewLabel.Text = Texto
NewLabel.Visibl e = True
NewLabel.Top = UBound(Row) * 10
Dim List(UBound(Row )) As Label
List(UBound(Row )) = NewLabel
Controls.Add(Ne wLabel)
End Sub
But I don't know what to do to add all new created labels to the public
array List
Of course, in my code, each time the function is called the List Array
is cleared, but I don't know how to use the Public List (If I delete
the "Dim List(UBound(Row )) As Label" then I get the error: Object
reference not set. How can I set this instance reference?
Thanks a lot.
My control has this function:
Sub AddRow(ByVal Texto As String)
When I execute AddRow("Sample" ) I want that my control adds a label to
an array and sets the text to the latest label in the array.
This is what I've done:
Public Row(0) As String
Public List() As Label
Sub AddRow(ByVal Texto As String)
ReDim Preserve Row(UBound(Row) + 1)
Row(UBound(Row) ) = Texto
Dim NewLabel As New Label
NewLabel.Name = Texto
NewLabel.Size = New System.Drawing. Size(39, 13)
NewLabel.TabInd ex = 0
NewLabel.Text = Texto
NewLabel.Visibl e = True
NewLabel.Top = UBound(Row) * 10
Dim List(UBound(Row )) As Label
List(UBound(Row )) = NewLabel
Controls.Add(Ne wLabel)
End Sub
But I don't know what to do to add all new created labels to the public
array List
Of course, in my code, each time the function is called the List Array
is cleared, but I don't know how to use the Public List (If I delete
the "Dim List(UBound(Row )) As Label" then I get the error: Object
reference not set. How can I set this instance reference?
Thanks a lot.