0

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

3
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by Luc001
0
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
0

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()
0

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.

Edited by Luc001: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.