Results 1 to 5 of 5

Thread: Texbox to Textbox?

  1. #1

    Thread Starter
    Fanatic Member TTn's Avatar
    Join Date
    Jul 2004
    Posts
    708

    Texbox to Textbox?

    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)

  2. #2
    Frenzied Member
    Join Date
    Jul 2005
    Posts
    1,521

    Re: Texbox to Textbox?

    Does the main form get updated when the user clicks a button to close it? It should be easy to do that.

    This is the code on the main form
    VB Code:
    1. Private Sub Button1_Click(sender as System.Object, e as System.Eventargs) Handles Button1.Click
    2.    Dim NewFrm as New Form2
    3.  
    4.    NewFrm.TextBox1.Text = TextBox1.Text
    5.    If NewFrm.Show = DialogResult.Ok Then
    6.       TextBox1.Text = NewFrm.TextBox1.Text
    7.    End If
    8. End Sub

  3. #3

    Thread Starter
    Fanatic Member TTn's Avatar
    Join Date
    Jul 2004
    Posts
    708

    Re: Texbox to Textbox?

    Thanks, but no, when it get's changed. I thought I was clear on that
    Your example didn't seem to work either.

    This is the event I want to update the main form with.
    This event is in the form, that was loaded by the main form.

    VB Code:
    1. Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
    2.  
    3. 'how to update the main form's TexBox2.text, with the contents of TextBox1.text
    4.  
    5. End Sub

  4. #4
    Fanatic Member
    Join Date
    May 2005
    Posts
    898

    Re: Texbox to Textbox?

    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         Dim fr As New Form1
    3.         AddHandler fr.TextBox1.TextChanged, AddressOf ChangeHandler
    4.  
    5.         fr.Show()
    6.     End Sub
    7.  
    8.     Private Sub ChangeHandler(ByVal sender As Object, ByVal e As EventArgs)
    9.         Me.TextBox1.Text = DirectCast(sender, TextBox).Text
    10.     End Sub
    "so just keep in mind that fantasy is not the same as realtiy and make sure u remember that wii sports may be fun but u cant count on it as exercise ok cool bye" - HungarianHuman

  5. #5

    Thread Starter
    Fanatic Member TTn's Avatar
    Join Date
    Jul 2004
    Posts
    708

    Re: Texbox to Textbox?

    Thank a centillion!

    RESOLVED
    I've rated your post!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width