How to get a value from other forms
-
Hi all Can anyone tell me how to get a value from other forms? For example, I have two forms on the project, Form1 and Form2. And I have a textbox and a button on Form1, when clicking the button, Form2 opened with a listbox on it. The problem is I want the selected item on the listbox shown in the textbox on Form1, can anyone hepl me this? Thankz advance:zzz::zzz:
-
Hi all Can anyone tell me how to get a value from other forms? For example, I have two forms on the project, Form1 and Form2. And I have a textbox and a button on Form1, when clicking the button, Form2 opened with a listbox on it. The problem is I want the selected item on the listbox shown in the textbox on Form1, can anyone hepl me this? Thankz advance:zzz::zzz:
You can expose values as properties, or pass them using delegates.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
You can expose values as properties, or pass them using delegates.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
You can expose values as properties, or pass them using delegates.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
How would you do this because I've had the same problem before and have had to find a less-than-perfect workaround. I don't think properties would work because the first form wont know when the selected index of the listbox on the second form has changed and therefore wont know when to update its textbox(unless you had a thread that continually checked). How would you use delegates to do it?
There are 10 types of people in the world, those who understand binary and those who dont.
-
Can you give more explaination about how to do it with delegates? Thankz:rolleyes::rolleyes:
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
How would you do this because I've had the same problem before and have had to find a less-than-perfect workaround. I don't think properties would work because the first form wont know when the selected index of the listbox on the second form has changed and therefore wont know when to update its textbox(unless you had a thread that continually checked). How would you use delegates to do it?
There are 10 types of people in the world, those who understand binary and those who dont.
smyers wrote:
I don't think properties would work because the first form wont know when the selected index of the listbox on the second form has changed and therefore wont know when to update its textbox(unless you had a thread that continually checked
That's why you use delegates.
smyers wrote:
How would you use delegates to do it?
Create a delegate that passes the value you want to broadcast, in the form with the control that changes. Hook this delegate to a method in the form that you want to inform of a changed value.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
smyers wrote:
I don't think properties would work because the first form wont know when the selected index of the listbox on the second form has changed and therefore wont know when to update its textbox(unless you had a thread that continually checked
That's why you use delegates.
smyers wrote:
How would you use delegates to do it?
Create a delegate that passes the value you want to broadcast, in the form with the control that changes. Hook this delegate to a method in the form that you want to inform of a changed value.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
Yes, almost always.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
Yes, almost always.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
smyers wrote:
I don't think properties would work because the first form wont know when the selected index of the listbox on the second form has changed and therefore wont know when to update its textbox(unless you had a thread that continually checked
That's why you use delegates.
smyers wrote:
How would you use delegates to do it?
Create a delegate that passes the value you want to broadcast, in the form with the control that changes. Hook this delegate to a method in the form that you want to inform of a changed value.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )