G
Guest
Hi,
I have built a control consisting of two listboxes and a button. The idea is
that I populat ethe list on the left, and the user selects items that are
added to the listbox on the right. This list is exposed by my user control as
an array.
I want to bve able to add multiple controls at runtime (basically one for
each parameter of a stored procedure that the user will select from a
drop-down).
I tried to test this idea having new controls added to an array but I get an
error 'Object reference not set to an instance of an object'
How should I do this in VB.NET please?
here is the code I have:
Dim tb As New TabPage
Dim ls() As ListSelector
Static count As Int16
tabParams.TabPages.Add(tb)
tb.Text = count
Dim listSel As New ListSelector
ls(count) = listSel
tb.Controls.Add(ls(count))
With ls(count)
.DataList = Nothing
.Location = New System.Drawing.Point(16, 8)
.Name = "ListSelector1"
.SelectedList = Nothing
.Size = New System.Drawing.Size(368, 144)
.TabIndex = 0
End With
count = count + 1
I have built a control consisting of two listboxes and a button. The idea is
that I populat ethe list on the left, and the user selects items that are
added to the listbox on the right. This list is exposed by my user control as
an array.
I want to bve able to add multiple controls at runtime (basically one for
each parameter of a stored procedure that the user will select from a
drop-down).
I tried to test this idea having new controls added to an array but I get an
error 'Object reference not set to an instance of an object'
How should I do this in VB.NET please?
here is the code I have:
Dim tb As New TabPage
Dim ls() As ListSelector
Static count As Int16
tabParams.TabPages.Add(tb)
tb.Text = count
Dim listSel As New ListSelector
ls(count) = listSel
tb.Controls.Add(ls(count))
With ls(count)
.DataList = Nothing
.Location = New System.Drawing.Point(16, 8)
.Name = "ListSelector1"
.SelectedList = Nothing
.Size = New System.Drawing.Size(368, 144)
.TabIndex = 0
End With
count = count + 1