Question : Add textboxes at run time in vb.net 2003

How can I add textboxes to my form at run time.   I need to loop through after loading a dataset.  I have a windows application in vb.net 2003.

I get the error  Too many arguments to 'Public Overridable Sub Add(value As System.Windows.Forms.Control)'.

thanks
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
Dim cmd3 As New SqlClient.SqlDataAdapter("Select *   from tblPatientNote where lngPatientid  = '" & lngpatientid & "' order by bytNote, dtmcreate desc", Connection1)
        Dim countnotes As Integer
        Dim note, strnote, strcreate, memnote, dtmcreate, notebc, notev, strnotev, strcreatev, memnotev, dtmcreatev
        Try
            countnotes = cmd3.Fill(dsNotes, "tblPatientNote")
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
        Dim numCtls As Integer = 5
        Dim i As Integer = 0
        Do While i <> countnotes

            ' Do While i < numCtls
            Dim ctlLabel As New Label
            ctlLabel.Name = "Label" & i.ToString()
            ctlLabel.Text = "Here's Text box #" & i.ToString() & ":"

            Panel1.Controls.Add(ctlLabel, 0, i)
            Dim ctlTextBox As New TextBox
            ctlTextBox.Name = "ctlTextBox" & i.ToString()
            ctlTextBox.Text = "TextBox" & i.ToString()
            Panel1.Controls.Add(ctlTextBox, 1, i)
            i += 1
            'End While



            '        i = i + 1
        Loop

Answer : Add textboxes at run time in vb.net 2003

Try to use a NEW label every time. Like this:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
Do While i < countnotes 'This is better, even if it's not really needed
	Dim myLabel As New Label 'Maybe THIS solves your problem
	myLabel.Text = "Label " & i
	topposition += 3 'The shorter way ;-)
	myLabel.Location = New Point(5, topposition)
	'I think it's already False, but to be sure ...
	myLabel.AutoSize = False
	myLabel.Height = 24
	myLabel.Width = 176
	Panel1.Controls.Add(myLabel)
	i += 1 'The shorter way again ;-)
Loop
Random Solutions  
 
programming4us programming4us