Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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?

Can you bind the beautiful Pleiades, and can you loose the cords of Orion? - God to Job...
Posted

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...

Can you bind the beautiful Pleiades, and can you loose the cords of Orion? - God to Job...
  • *Experts*
Posted
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.
Posted
i see, okok, so this onli applies to startup forms?
Can you bind the beautiful Pleiades, and can you loose the cords of Orion? - God to Job...
Posted

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.

Stress is directly associated with programming. But if I keep moving on to new stresses, then I am doing my job correctly!
  • *Experts*
Posted
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.
Posted

interesting...

 

how do i pass it through a constructor?

Can you bind the beautiful Pleiades, and can you loose the cords of Orion? - God to Job...
  • *Experts*
Posted

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.

Posted
i see, cool, i did not know that we could just add watever parameters we like to form our own version of a constructor!
Can you bind the beautiful Pleiades, and can you loose the cords of Orion? - God to Job...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...