sjchin Posted March 23, 2003 Posted March 23, 2003 RE: How to call Refresh Form? Hi guys, If i have 2 form,name it as Form1, Form2. In form1, assume that it display summary of all records, when i call form2 to update somthing and will back to form1, how can i call form1 to refresh my result? Assume that in form1 i have a sub routine,which used to reload all my result to listview. How can i call form1's sub routine in form2 to reload my listview? Assume that form1 is show at the back of form2. Beside this, how can i do a call new form2 and not allow it reopen again? In VB6, we have form2.show vbmodal, so what can do in vb.Net? Thanks and wait for prompts reply. Quote
*Gurus* divil Posted March 23, 2003 *Gurus* Posted March 23, 2003 You can show the second form with its ShowDialog method: Dim f As New Form2() f.ShowDialog(Me) Then from the second form, you should be able to access the Owner property, cast it to the correct type and run a subroutine on it: DirectCast(Me.Owner, Form1).MyMethod() Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
sjchin Posted March 24, 2003 Author Posted March 24, 2003 divil, Thanks you for your help. Beside this, I still have other question, wish you can do me a favour. :> In VB.Net, beside using showdialog, how can i know which form is calling from which form? Example: Assume i have 2 form, Form1 and form2 Form1 contain textbox1 form1 contain sub routine call setValue (This routine will set textbox value) In form1 ,i will write: Dim f2 as new form2 f2.show In form2, i wish to call form1 value, but if i using : dim f1 as new form1 f1.setvalue f1.show it will appear new form1, which not overwrite the exisitng form1, so may i know how to solve this problem? using showdialog will force user to close form2 before goto form1, i want allow user to click on form1 instead close of form2. Beside this,does any command can make the form2 show only once form? I have try click on the form1 button twice, it will appear 2 form2. The way i using is '--> on click button of Form1 dim f as new form2 f.show Thanks and wait for prompts reply :> Quote
*Gurus* divil Posted March 24, 2003 *Gurus* Posted March 24, 2003 I usually pass a reference to the "creating" form in the new form's constructor. That was the created form can store this reference and therefore call back to the main form if it needs to. As for your other question, you can just keep a reference around in the first form and see if it's set or not. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.