Closed Thread
Results 1 to 8 of 8

Thread: Win Forms question

  1. #1
    bogus is offline Newbie
    Join Date
    Sep 2008
    Posts
    6
    Rep Power
    0

    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. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,174
    Blog Entries
    13
    Rep Power
    114

    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

  4. #3
    bogus is offline Newbie
    Join Date
    Sep 2008
    Posts
    6
    Rep Power
    0

    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

  5. #4
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,174
    Blog Entries
    13
    Rep Power
    114

    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

  6. #5
    bogus is offline Newbie
    Join Date
    Sep 2008
    Posts
    6
    Rep Power
    0

    Re: Win Forms question

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

  7. #6
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,174
    Blog Entries
    13
    Rep Power
    114

    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

  8. #7
    bogus is offline Newbie
    Join Date
    Sep 2008
    Posts
    6
    Rep Power
    0

    Re: Win Forms question

    In this context:

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

    textBox1 seems not be visible

  9. #8
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,174
    Blog Entries
    13
    Rep Power
    114

    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

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Question on html forms and php
    By HiRo in forum PHP Development
    Replies: 7
    Last Post: 10-17-2010, 12:51 AM
  2. Simple Forms Question using Resize Event
    By vt2009 in forum C# Programming
    Replies: 1
    Last Post: 10-17-2010, 12:50 AM
  3. QUESTION regarding getting values on forms
    By hardinera in forum PHP Development
    Replies: 3
    Last Post: 03-09-2010, 05:43 PM
  4. Using variables in different forms question
    By skilletsteve in forum Visual Basic Programming
    Replies: 2
    Last Post: 08-31-2006, 08:39 AM
  5. Windows Forms MDI question.
    By hoser2001 in forum C# Programming
    Replies: 10
    Last Post: 08-11-2006, 04:36 PM

Tags for this Thread

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