Click here to Skip to main content
15,915,044 members
Home / Discussions / C#
   

C#

 
GeneralRe: Speechlib Pin
wernlin27-Nov-13 5:30
wernlin27-Nov-13 5:30 
Questionchange text from form Pin
messages25-Nov-13 3:33
messages25-Nov-13 3:33 
AnswerRe: change text from form Pin
Richard MacCutchan25-Nov-13 4:54
mveRichard MacCutchan25-Nov-13 4:54 
GeneralRe: change text from form Pin
messages25-Nov-13 5:20
messages25-Nov-13 5:20 
GeneralRe: change text from form Pin
Richard MacCutchan25-Nov-13 5:39
mveRichard MacCutchan25-Nov-13 5:39 
GeneralRe: change text from form Pin
messages25-Nov-13 5:50
messages25-Nov-13 5:50 
GeneralRe: change text from form Pin
Richard MacCutchan25-Nov-13 6:23
mveRichard MacCutchan25-Nov-13 6:23 
AnswerRe: change text from form Pin
OriginalGriff25-Nov-13 5:04
mveOriginalGriff25-Nov-13 5:04 
That doesn't do what you want at all - and it is a very poor bit of design.
All that happens is that you get an increasing number of "hidden" forms building up behind the scenes until you run out of memory...

Instead, think of one form (Form1) as the Parent, and the other (Form2) as the child.
In the Form1 button press:
C#
private void button1_Click(object sender, EventArgs e)
    {
    Form2 form2 = new Form2();
    form2().Text = textBoxform1.Text;
    Hide();
    form2.ShowDialog();
    Text = form2.NewValue;
    Show();
    }
This means that Form1 will hide itself, display it's child Form2, and redisplay itself when Form2 closes.
Then, add a property to Form2, and change the button handler:
C#
public string NewValue { get { return textBoxform2.Text; } }
private void button1_Click(object sender, EventArgs e)
    { 
    Close();
    }

Form2 then closes itself when you press the button, and allows Form1 to get the new value for itself. That way, Form2 doesn't need to know that Form1 even exists, and the interconnections between the forms is reduced to the minimum.
GeneralRe: change text from form Pin
messages25-Nov-13 5:19
messages25-Nov-13 5:19 
GeneralRe: change text from form Pin
OriginalGriff25-Nov-13 5:23
mveOriginalGriff25-Nov-13 5:23 
GeneralRe: change text from form Pin
messages25-Nov-13 5:48
messages25-Nov-13 5:48 
GeneralRe: change text from form Pin
OriginalGriff25-Nov-13 6:00
mveOriginalGriff25-Nov-13 6:00 
GeneralRe: change text from form Pin
messages25-Nov-13 6:32
messages25-Nov-13 6:32 
GeneralRe: change text from form Pin
OriginalGriff25-Nov-13 7:59
mveOriginalGriff25-Nov-13 7:59 
GeneralRe: change text from form Pin
messages26-Nov-13 3:59
messages26-Nov-13 3:59 
GeneralRe: change text from form Pin
OriginalGriff26-Nov-13 5:01
mveOriginalGriff26-Nov-13 5:01 
GeneralRe: change text from form Pin
messages26-Nov-13 5:22
messages26-Nov-13 5:22 
GeneralRe: change text from form Pin
OriginalGriff26-Nov-13 5:56
mveOriginalGriff26-Nov-13 5:56 
AnswerRe: change text from form Pin
BillWoodruff25-Nov-13 5:08
professionalBillWoodruff25-Nov-13 5:08 
GeneralRe: change text from form Pin
messages25-Nov-13 5:26
messages25-Nov-13 5:26 
GeneralRe: change text from form Pin
BillWoodruff25-Nov-13 12:39
professionalBillWoodruff25-Nov-13 12:39 
AnswerRe: change text from form Pin
Vinh Nguyen26-Nov-13 0:01
Vinh Nguyen26-Nov-13 0:01 
QuestionHow can I access the properties of this object? Pin
turbosupramk325-Nov-13 3:20
turbosupramk325-Nov-13 3:20 
AnswerRe: How can I access the properties of this object? Pin
Vinh Nguyen25-Nov-13 3:52
Vinh Nguyen25-Nov-13 3:52 
AnswerRe: How can I access the properties of this object? Pin
OriginalGriff25-Nov-13 5:10
mveOriginalGriff25-Nov-13 5:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.