Sharing data between forms???
-
Do you know how to use the data in “textbox1.Text” (Form1) in a method on another form (Form2) all within the same namespace??? Kevin@upgrade1.com
-
Do you know how to use the data in “textbox1.Text” (Form1) in a method on another form (Form2) all within the same namespace??? Kevin@upgrade1.com
You can do it a couple of ways depending on the relationship between Form1 and Form2. (e.g. Form1 creates Form2, Form2 creates Form1 or Form3 creates both). For "Form1 creates Form2", you can pass an instance of Form1 to Form2
public Form2 { public Form2(Form1 f) { } } ...
and then when Form1 is constructing Form2:Form2 f = new Form2(this);
if "Form2 creates Form1", then you can just setup a public property in Form1 that gets the text from the label but you must keep an instance of Form1 as a field in Form2 so that your function can access it. And the "Form3 creates both", then construct Form1 first, and then pass its instance to Form2. --Adam Turner -
Do you know how to use the data in “textbox1.Text” (Form1) in a method on another form (Form2) all within the same namespace??? Kevin@upgrade1.com
kvnsdr wrote: Do you know how to use the data in “textbox1.Text” (Form1) in a method on another form (Form2) all within the same namespace??? That's only a matter of public/protected/private member visibility.