fkheng Posted June 15, 2003 Posted June 15, 2003 Er....wat does .repaint do for a form? is it like a refresh? Also, I want to call form B from form A which, i want to close after calling the form B. My code in form A is like : formB.show() me.close() however, after i do this, the whole program terminates if i do formB.show() me.hide() with this, formA is still active... someone did suggest to set the formA to nothing, how do I do that? also, is there a better way around this? Quote Can you bind the beautiful Pleiades, and can you loose the cords of Orion? - God to Job...
*Experts* mutant Posted June 15, 2003 *Experts* Posted June 15, 2003 formB.Show() me.Hide() Works fine, what event are doing that in? Quote
fkheng Posted June 15, 2003 Author Posted June 15, 2003 yeah i can do this, but when i close form B, form a will still be active since it is actually hiding there, is there anyway of fully closing it at the same time doing formB.show()? i'm doing htis when i click some button... Quote Can you bind the beautiful Pleiades, and can you loose the cords of Orion? - God to Job...
*Experts* mutant Posted June 15, 2003 *Experts* Posted June 15, 2003 If the FormA is the one you start with you cant fully close it as it was the form that started the message loop for the application and if you close it, app will shut down. You have to hide it. Quote
fkheng Posted June 15, 2003 Author Posted June 15, 2003 i see, okok, so this onli applies to startup forms? Quote Can you bind the beautiful Pleiades, and can you loose the cords of Orion? - God to Job...
Shims Posted June 15, 2003 Posted June 15, 2003 Actually fkheng, you are right. I have stumbled upon this little doozy as well. When you hide "FORM A" and show "FORM B", there is no way to get back to the original "FORM A". You have to create a new instance of "B", and hide "A". Dim newFormA as New FormA newFormA.show() me.hide Here's where it get tricky, the only way to close the whole app using me.close is if you do it on the first created form. So if you now want to go back to formA from FormB, just Me.Close FormB and create a new instance of FormA. If at any time you want to shut down the whole program, use "End." At all times "except at first" you will have 2 forms running--the hidden FORMA and the other currently visible file. Quote Stress is directly associated with programming. But if I keep moving on to new stresses, then I am doing my job correctly!
*Experts* mutant Posted June 15, 2003 *Experts* Posted June 15, 2003 You can get back to the original one, you would have to pass in the instance of the original one to the second one through constructor and then just do variablewithinstance.Show() in the second one. Quote
Shims Posted June 15, 2003 Posted June 15, 2003 I see... You learn something new everyday. Maybe you can help me with my thread http://www.xtremedotnettalk.com/showthread.php?threadid=73172 Quote Stress is directly associated with programming. But if I keep moving on to new stresses, then I am doing my job correctly!
fkheng Posted June 17, 2003 Author Posted June 17, 2003 interesting... how do i pass it through a constructor? Quote Can you bind the beautiful Pleiades, and can you loose the cords of Orion? - God to Job...
*Experts* mutant Posted June 17, 2003 *Experts* Posted June 17, 2003 Go to Sub New in your second form: And modify it like this: Dim form1nd as Form1 'variable to hold the instance outside of 'constructor Public Sub New(ByVal firstform as Form1) 'accept an instance MyBase.New() InitializeComponenets() form1nd = firstform 'get the instance to a vriable you can use 'outside of constructor end sub From there you will just have to use the form1nd variable to access the instance of that form. And when you initialize your second form in first one do this: Dim Formtwo as new Form2(Me) This will pass in your form's instance. Quote
fkheng Posted June 18, 2003 Author Posted June 18, 2003 i see, cool, i did not know that we could just add watever parameters we like to form our own version of a constructor! Quote Can you bind the beautiful Pleiades, and can you loose the cords of Orion? - God to Job...
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.