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
C# Other forms in same solution help
Page 1 of 14 Replies - 590 Views - Last Post: 16 November 2010 - 02:52 PM
Replies To: C# Other forms in same solution help
#2
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.
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.
#3
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.
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.
#4
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
Thanks Aaron1178
private void functionToolStripMenuItem_Click(object sender, EventArgs e)
{
Form3 f3 = new Form3();
f3.Show();
}
Thanks Aaron1178
#5
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?
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote




|