Displaying Values of child form in the Parent ....
-
Hi... I have two forms in my windows application. Form1 and Form2. In Form1 I have 1 Label and a button. In Form2 I have just a button. When clicking on this Form1 button I am opening Form2. In Form2 button Click event I have to hide the Form2 and have to show the value "HI" in the Form1 Label. To do this some one suggested me use delegates. Is this only way to do this?
your peter
-
Hi... I have two forms in my windows application. Form1 and Form2. In Form1 I have 1 Label and a button. In Form2 I have just a button. When clicking on this Form1 button I am opening Form2. In Form2 button Click event I have to hide the Form2 and have to show the value "HI" in the Form1 Label. To do this some one suggested me use delegates. Is this only way to do this?
your peter
-
Hi... I have two forms in my windows application. Form1 and Form2. In Form1 I have 1 Label and a button. In Form2 I have just a button. When clicking on this Form1 button I am opening Form2. In Form2 button Click event I have to hide the Form2 and have to show the value "HI" in the Form1 Label. To do this some one suggested me use delegates. Is this only way to do this?
your peter
Hi.. :) you can do thats by connect even form . --- Form1 --- private void button1_Click(object sender, System.EventArgs e) { Form2 FRM = new Form2(this); FRM.show(); } public void SetLabelValue(string MSG) { Label1.Text = MSG; } --- Form2 --- Form FRM1 = null; public Form2(Form1 frm) { // Required for Windows Form Designer support InitializeComponent(); this.FRM1 = frm ; } private void button1_Click(object sender, System.EventArgs e) { this.FRM1.SetLabelValue("HI"); FRM1.show(); }
-
Hi.. :) you can do thats by connect even form . --- Form1 --- private void button1_Click(object sender, System.EventArgs e) { Form2 FRM = new Form2(this); FRM.show(); } public void SetLabelValue(string MSG) { Label1.Text = MSG; } --- Form2 --- Form FRM1 = null; public Form2(Form1 frm) { // Required for Windows Form Designer support InitializeComponent(); this.FRM1 = frm ; } private void button1_Click(object sender, System.EventArgs e) { this.FRM1.SetLabelValue("HI"); FRM1.show(); }
Thank You
your peter
-
Hi.. :) you can do thats by connect even form . --- Form1 --- private void button1_Click(object sender, System.EventArgs e) { Form2 FRM = new Form2(this); FRM.show(); } public void SetLabelValue(string MSG) { Label1.Text = MSG; } --- Form2 --- Form FRM1 = null; public Form2(Form1 frm) { // Required for Windows Form Designer support InitializeComponent(); this.FRM1 = frm ; } private void button1_Click(object sender, System.EventArgs e) { this.FRM1.SetLabelValue("HI"); FRM1.show(); }
This is a poor solution because it couples the forms together. If you want to change the way your application works in the future it will be more difficult to make the modifications.
Upcoming FREE developer events: * Developer Day Scotland Recent blog posts: * Different ways to add point data in SQL Server 2008 * Spatial References in SQL Server 2008 My website |