+ Reply to Thread
Results 1 to 8 of 8

Thread: Win Forms question

  1. #1
    Newbie bogus is an unknown quantity at this point
    Join Date
    Sep 2008
    Posts
    6

    Win Forms question

    Hello,
    Consider a WinForm A and a WinForm B. I want to click a button from B and write something in a textBox from A. Can you help me with that?
    Thanks

  2. #2
    Xav
    Xav is offline
    Code Slinger Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav's Avatar
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,210
    Blog Entries
    13

    Re: Win Forms question

    Do you have a reference to the form instance from WinForm B? If not, then use the static keyword on the method declaration that writes the text in WinForm A.

    Quote Originally Posted by Jordan View Post
    Good members, like yourself, stick around and post for ages to come!
    Mr. Xav | Blog | Forums

  3. #3
    Newbie bogus is an unknown quantity at this point
    Join Date
    Sep 2008
    Posts
    6

    Re: Win Forms question

    It's like this, i got my main form..FormA..i push a button and create a FormB (FormB x =new FormB(); x.ShowDialog(); ) now i want to push a button from x and write something in a textbox from my main form..there is no instance of FormA

  4. #4
    Xav
    Xav is offline
    Code Slinger Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav's Avatar
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,210
    Blog Entries
    13

    Re: Win Forms question

    In FormA, try writing a method like this in Form A:
    Code:
    public static WriteText(string TheText)
    {
     textBox1.Text = TheText;
    }
    Then, in Form B, try this:
    Code:
    FormA.WriteText("Hello world");
    I dunno if it works or not? The "static" keyword should do the trick.

    Quote Originally Posted by Jordan View Post
    Good members, like yourself, stick around and post for ages to come!
    Mr. Xav | Blog | Forums

  5. #5
    Newbie bogus is an unknown quantity at this point
    Join Date
    Sep 2008
    Posts
    6

    Re: Win Forms question

    thanks for your reply Xav i will see try and let you know about the results

  6. #6
    Xav
    Xav is offline
    Code Slinger Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav's Avatar
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,210
    Blog Entries
    13

    Re: Win Forms question

    Ok.

    Quote Originally Posted by Jordan View Post
    Good members, like yourself, stick around and post for ages to come!
    Mr. Xav | Blog | Forums

  7. #7
    Newbie bogus is an unknown quantity at this point
    Join Date
    Sep 2008
    Posts
    6

    Re: Win Forms question

    In this context:

    public static WriteText(string TheText)
    {
    textBox1.Text = TheText;
    }

    textBox1 seems not be visible

  8. #8
    Xav
    Xav is offline
    Code Slinger Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav's Avatar
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,210
    Blog Entries
    13

    Re: Win Forms question

    You put that on Form A, which contains the textbox.

    Quote Originally Posted by Jordan View Post
    Good members, like yourself, stick around and post for ages to come!
    Mr. Xav | Blog | Forums

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Fading Forms in VB.NET
    By Xav in forum VB Tutorials
    Replies: 19
    Last Post: 08-16-2008, 09:42 AM
  2. Newbe C# Platform question
    By cob98tp in forum C# Programming
    Replies: 28
    Last Post: 07-30-2008, 09:01 AM
  3. Using variables in different forms question
    By skilletsteve in forum Visual Basic Programming
    Replies: 2
    Last Post: 08-31-2006, 11:39 AM
  4. Question about Form's On_Closing event
    By hoser2001 in forum C# Programming
    Replies: 3
    Last Post: 08-22-2006, 08:25 AM
  5. Windows Forms MDI question.
    By hoser2001 in forum C# Programming
    Replies: 10
    Last Post: 08-11-2006, 07:36 PM

Bookmarks

Posting Permissions

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