Get Data from Lookup Form
-
I have a Main Form call FormA, FormA call a Lookup Form named FormB using following Code
FormB formb = new FormB(); FormB.Show();
in FormB there is a textboxA to let the user to enter certain string value that need to passback to FormA and execute several statements in FormA when user press a button in FormB Any1 has any idea how to do that?my fren advise me to use delegate but i not very familiar with delegate coding structure, i greatly appreciated if any1 can provide the sample coding to do that;) -
I have a Main Form call FormA, FormA call a Lookup Form named FormB using following Code
FormB formb = new FormB(); FormB.Show();
in FormB there is a textboxA to let the user to enter certain string value that need to passback to FormA and execute several statements in FormA when user press a button in FormB Any1 has any idea how to do that?my fren advise me to use delegate but i not very familiar with delegate coding structure, i greatly appreciated if any1 can provide the sample coding to do that;)There are many ways to accomplish your task. 1) Best way would be to make a custom event. As you told that you dont know much about delegates so I think it will be even difficult for you. 2) Make a static method in FormA and call it from FormB's click event handler by either passing it this (FormB object) as an argument if FormB is not class variable in FormA. In that method get all the values from FormB and then you could just close FormB or even destroy it. 3)In the click event handler of FormB, get its Parent by FormB.Parent, this will yeild you the reference to FormA's object. Now you could do anything with it. You can use any of the above mentioned way. Hope it helps.
Regards Khalid
-
There are many ways to accomplish your task. 1) Best way would be to make a custom event. As you told that you dont know much about delegates so I think it will be even difficult for you. 2) Make a static method in FormA and call it from FormB's click event handler by either passing it this (FormB object) as an argument if FormB is not class variable in FormA. In that method get all the values from FormB and then you could just close FormB or even destroy it. 3)In the click event handler of FormB, get its Parent by FormB.Parent, this will yeild you the reference to FormA's object. Now you could do anything with it. You can use any of the above mentioned way. Hope it helps.
Regards Khalid