4 Replies - 709 Views - Last Post: 16 November 2010 - 02:52 PM Rate Topic: -----

#1 aaron1178  Icon User is offline

  • Dovakiin, Dragonborn
  • member icon

Reputation: 169
  • View blog
  • Posts: 1,298
  • Joined: 22-October 08

C# Other forms in same solution help

Posted 16 November 2010 - 01:28 PM

Hey,
Well in my solution i have added another form with a rtf area right, and an button, i would like to know when i click that button how do i get the text and put it in my main rtf.

Also, should this new form be an MDI

Thanks Aaron1178
Is This A Good Question/Topic? 0
  • +

Replies To: C# Other forms in same solution help

#2 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4490
  • View blog
  • Posts: 7,822
  • Joined: 08-June 10

Re: C# Other forms in same solution help

Posted 16 November 2010 - 02:01 PM

Please try to explain your question better. It is extremely difficult to understand what you are asking for.

I'm guessing that this is the old "how do I get data from Form2 to Form1" question. The answer to that lies in events. Of course, there's more than one way to do this, and the answer (in my opinion) changes if Form2 is a modal dialog or not.

So my first question is, are you using Show() or ShowDialog(). If it's ShowDialog(), then just make a public property on Form2 that gets the RTB's text.

If it's not modal (Show()), then your best bet is to create an event on Form2 and have Form1 subscribe to it. Fire the event when the user clicks a button.
Was This Post Helpful? 1
  • +
  • -

#3 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,960
  • Joined: 21-March 08

Re: C# Other forms in same solution help

Posted 16 November 2010 - 02:04 PM

You should look into using Custom Events. Most people would get the instance of the form, then use Properties to get the text. While it works, it's really not the best way of doing it. Form1 should be concerned with Form1. It doesn't care about Form2. Form2 should only care about Form2. Using events, Form2 can say, "Hey I did something". Anybody who wants to know when Form2 does this can subscribe to the event. This way, Form2 cares only about itself and not any other forms.

EDITED: or as says it you are doing it as a dialog box. Events wouldn't work if you are showing the second form as a dialog.
Was This Post Helpful? 0
  • +
  • -

#4 aaron1178  Icon User is offline

  • Dovakiin, Dragonborn
  • member icon

Reputation: 169
  • View blog
  • Posts: 1,298
  • Joined: 22-October 08

Re: C# Other forms in same solution help

Posted 16 November 2010 - 02:43 PM

Ok sorry about the lack of data here is the method i call it on
 private void functionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form3 f3 = new Form3();
            f3.Show();
        }




Thanks Aaron1178
Was This Post Helpful? 0
  • +
  • -

#5 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4490
  • View blog
  • Posts: 7,822
  • Joined: 08-June 10

Re: C# Other forms in same solution help

Posted 16 November 2010 - 02:52 PM

So now that you've shown us that you're using a non-modal dialog, have you looked at the link Eclipsed has provided? Have you tried it out?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1