I have a textbox on form1, how can i get that textbox to display the same information on form2 automatically?
form2.textbox1.box = form1.textbox1.box
please help thanks
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Form2.TextBox1.Text = TextBox1.Text
Form2.Show()
End Sub
End Class
doesnt work
If you do not need to send just the text from Form1's TextBox1 to Form2's TextBox1, but need to copy the entire TextBox control from Form1 and add it Form2, see if this helps.
Dim txt As TextBox = TextBox1
'txt.Location = New Point(0, 0) '// If Location needs to be changed.
Form2.Controls.Add(txt)
Form2.Show()
Hi,
I've used this in VB 2008 and works:
Dim form2 As New Form2
form2.TextBox1.Text = Me.TextBox1.Text
form2.TextBox1.Enabled = True
form2.Show()
Me.Hide()
All you need to do is add a button and textbox in form1 and textbox in form2.
Put then this code into the button event.
However, if you really want to copy the entire textbox, location and size then Codeorder's code is better.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.