Click to See Complete Forum and Search --> : TextBox to TextBox?


TT(n)
October 14th, 2005, 10:36 PM
This must be a stupid question, but after an hour of trying it's now intelligent for me to ask.

How would I sync a form's textbox, with the main form's textbox?

When the user, click a button on the main form, another form loads up.
Then when they change the textbox, I want a textbox in the main form to be updated with that string. Simple right!

In the old VB6, this was completely trivial.
It seems that .NET is not as easy, perhaps for protection?
I tried delclaring the form, and texbox, but to no avail.


At a loss,
TT(n)

HanneSThEGreaT
October 15th, 2005, 02:54 AM
Yes in VB6, it was easier!!:p

Public Class Form1
Inherits System.Windows.Forms.Form

Private F2 As New Form2 'F2 is now form2

Private Sub TextBox1_LostFocus(ByVal sender AsObject, ByVal e As System.EventArgs) Handles TextBox1.LostFocus

F2.TextBox1.Text = Me.TextBox1.Text 'set the text equal

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

F2.Show() 'show the next form

End Sub

End Class

TT(n)
October 15th, 2005, 07:08 AM
RESOLVED


Thanks!

This is about what I thought it should be.
I was using Dim, instead of Private.

Duh
TTn



At the VBforum I got this example, which works too but is a little more involved. Pretty cool though, this is also what I suspected if not trivial.


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
On Error Resume Next
Dim fSound As New frmSound
AddHandler fSound.txt.TextChanged, AddressOf ChangeHandler
End Sub

Private Sub ChangeHandler(ByVal sender As Object, ByVal e As EventArgs)
Me.txt2.Text = DirectCast(sender, TextBox).Text
End Sub