Changing the Active Forms
-
By dafault form1 is the active form . How can we change the active form to form 2 such that after closing form1 our application wont be closed. neha
Are you saying that you'll have multiple forms open at the same time and that the user can close any of them and still keep the app running? Sounds like a job for seperate apps to me but I don't know all the details about what your doing... Ummm...You might want to try having either a Main function that declares and shows all the forms, or you might want to do the same thing in a hidden form. You can then go into the Project Properties and change the startup object to either Main or the hidden form. Now, you'r also going to have to handle the Close events of these forms so your Main or hidden form knows that all of your visible forms are closed so it knows when to quit. RageInTheMachine9532
-
Are you saying that you'll have multiple forms open at the same time and that the user can close any of them and still keep the app running? Sounds like a job for seperate apps to me but I don't know all the details about what your doing... Ummm...You might want to try having either a Main function that declares and shows all the forms, or you might want to do the same thing in a hidden form. You can then go into the Project Properties and change the startup object to either Main or the hidden form. Now, you'r also going to have to handle the Close events of these forms so your Main or hidden form knows that all of your visible forms are closed so it knows when to quit. RageInTheMachine9532
Thanks for the reply , but in my appln there are 7 forms & once I start executing the appln , My main startup form appears. ok. Now once I go from this startup form to form2 , I would like to close the startup form(form1). when I close the startup form (form1) then my application gets closed. So for this can u suggest any remedy so that I can transfer the active control from form1(startup) to form2 & can close startup form??
-
Thanks for the reply , but in my appln there are 7 forms & once I start executing the appln , My main startup form appears. ok. Now once I go from this startup form to form2 , I would like to close the startup form(form1). when I close the startup form (form1) then my application gets closed. So for this can u suggest any remedy so that I can transfer the active control from form1(startup) to form2 & can close startup form??
Then you might want to try something like Me.Hide() on your main form. Or Form1.Hide() when you enter the Activate code on Form2. RageInTheMachine9532
-
Then you might want to try something like Me.Hide() on your main form. Or Form1.Hide() when you enter the Activate code on Form2. RageInTheMachine9532
Currently Iam doing that only but then when Iam closing the main form ie form2 then my application is not getting closed. ie I am required to go to the close button from the VB menu to stop execution of the application. I dont know how far u can understand what I mean to say !!
-
Currently Iam doing that only but then when Iam closing the main form ie form2 then my application is not getting closed. ie I am required to go to the close button from the VB menu to stop execution of the application. I dont know how far u can understand what I mean to say !!
Now it sounds like your first form is a splash screen. What ever form is your startup form CANNOT be closed unless you want your entire app to be closed with it. Your startup form does NOT have to be visible when you app starts. You can start your app with Form1.Visible=False and have it Form2.Show, Form3.Show, whatever... But! You have to keep track of which Forms are open in your main form (Form1) and determine when Form1 either shows itself to be closed or closes on its own. RageInTheMachine9532
-
Currently Iam doing that only but then when Iam closing the main form ie form2 then my application is not getting closed. ie I am required to go to the close button from the VB menu to stop execution of the application. I dont know how far u can understand what I mean to say !!
I think there is a problem with your design assumptions and how Windows Forms apps work. It would appears that you think your application can stay open so long as there is ANY form in your app open:
Application | |
+-------+-------+-------+-------+
| | | | |
Form1 Form2 Form3 Form4 Form5This is just not the case. Your application depends on a main class, or Form, that is the central hub of your application. Something like this:
Application | Form1 |
+-------+-------+-------+-------+
| | | | |
Form2 Form3 Form4 Form5 Form6
| |
Form7 Form8Only when Form1 is closed can your application close, and in opposite terms, only so long as Form1 is open, even if its not visible, can your app stay open. In the latter example, Form2 can be your splash screen, Forms 3-6 can be options dialogs, editors, print previews, subsections of your app, whatever, ... But in all cases, Form1 MUST keep track of which forms are open and closed. RageInTheMachine9532
-
I think there is a problem with your design assumptions and how Windows Forms apps work. It would appears that you think your application can stay open so long as there is ANY form in your app open:
Application | |
+-------+-------+-------+-------+
| | | | |
Form1 Form2 Form3 Form4 Form5This is just not the case. Your application depends on a main class, or Form, that is the central hub of your application. Something like this:
Application | Form1 |
+-------+-------+-------+-------+
| | | | |
Form2 Form3 Form4 Form5 Form6
| |
Form7 Form8Only when Form1 is closed can your application close, and in opposite terms, only so long as Form1 is open, even if its not visible, can your app stay open. In the latter example, Form2 can be your splash screen, Forms 3-6 can be options dialogs, editors, print previews, subsections of your app, whatever, ... But in all cases, Form1 MUST keep track of which forms are open and closed. RageInTheMachine9532