Newbie: Stupid question about forms & variables...
-
This is probably a very silly question. I am opening a form(b) from within another form(a) and I am trying to get a variable from form(a) and display its contents in form(b). But I don't know how? I will also be updating the variables in form(a) from form(b)? I have searched for ideas, but not sure what to search for? Thanks in advance, Phil
"Rules are for the obedience of fools and the guidance of wise men"
-
This is probably a very silly question. I am opening a form(b) from within another form(a) and I am trying to get a variable from form(a) and display its contents in form(b). But I don't know how? I will also be updating the variables in form(a) from form(b)? I have searched for ideas, but not sure what to search for? Thanks in advance, Phil
"Rules are for the obedience of fools and the guidance of wise men"
Create a public property in form B that sets the variable in form B from Form B to A is more tricky, or you'll need to pass the object A itself to B or you'll have to create your own event. thus in form A you'll have something like:
MyForm B = new MyForm(); B.MyProperty = variablefromA; B.showDialog();
to pass the object A to form B you could pass it through the constructor (MyForm B = new MyForm(this);
) I hope for you this isn't homework...?V. Stop smoking so you can: enjoy longer the money you save.
-
This is probably a very silly question. I am opening a form(b) from within another form(a) and I am trying to get a variable from form(a) and display its contents in form(b). But I don't know how? I will also be updating the variables in form(a) from form(b)? I have searched for ideas, but not sure what to search for? Thanks in advance, Phil
"Rules are for the obedience of fools and the guidance of wise men"
There are generally two methods used: 1. Send a reference to form A to the constructor of form B, and store the reference in form B. Then you can access form A using the reference. 2. Make the variables in form A static, then you can access them from anywhere by specifying the class name of the form. This of course limits you to never create more than one instance of the form.
--- b { font-weight: normal; }
-
This is probably a very silly question. I am opening a form(b) from within another form(a) and I am trying to get a variable from form(a) and display its contents in form(b). But I don't know how? I will also be updating the variables in form(a) from form(b)? I have searched for ideas, but not sure what to search for? Thanks in advance, Phil
"Rules are for the obedience of fools and the guidance of wise men"
-
This is probably a very silly question. I am opening a form(b) from within another form(a) and I am trying to get a variable from form(a) and display its contents in form(b). But I don't know how? I will also be updating the variables in form(a) from form(b)? I have searched for ideas, but not sure what to search for? Thanks in advance, Phil
"Rules are for the obedience of fools and the guidance of wise men"
See this article: Passing values between forms[^]
Upcoming Scottish Developers events: * UK Security Evangelists On Tour (2nd November, Edinburgh) * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog
-
You beat me to it! :-D
Upcoming Scottish Developers events: * UK Security Evangelists On Tour (2nd November, Edinburgh) * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog