problem to display textbox of the second form

CharlieChau

Active member
Joined
Jun 15, 2004
Messages
26
Programming Experience
Beginner
I have two forms, the first form contents a button that activate the second form as the following:


Dim frmForm2 As Form2 = New Form2()
dim textbox1 as Textbox = new Textbox()
'put the location of the textbox
textbox1.location = System.Drawing.Point(16, 0)
'name of the textbox
textbox1.name = "txtname"
textbox1.text = " "
'add the textbox in the form2
me.controls.add(textbox1)
frmForm2.Show()

Somehow the textbox in the above code does not display on the second form, but on the first form. How can I make it display on the second form???
 
Instead of Me.Controls.add(textbox1) do frmForm2.Controls.add(textbox1).
The Me keyword refers to the form in which the code is contained.
 
Back
Top