Howto Change application's main form

Posted on 2005-05-13
Last Modified: 2006-11-18

how can I change the Application's main form (the form
I create within Application.Run(new someForm()), so I
can open another form, close this main form without the
Application will be closed. Is there a way around this
problem without writing code like this in Compact Framework ?:

while (!finished)
      if (showSomeForm)
           Application.Run(new someForm());
      else if (showSomeOtherForm)
          Application.Run(new someOtherForm());


Question by:eltic
    LVL 85

    Expert Comment

    by:Mike Tomlinson
    Hi eltic,

    I don't know if this works in the Compact Framework but in the full version of .Net you create your own instance of the ApplicationContext() class. I have posted two differenct approaches here:

    The link in that PAQ shows how to completely close one form and open another.  The code in the PAQ shows how to switch between the forms without closing them.

    Hope it helps...

    LVL 85

    Expert Comment

    by:Mike Tomlinson
    LVL 5

    Author Comment


    Unfortunatly, there is no ApplicationContext class in compact framework.
    Is there another way to play around this ?

    LVL 85

    Accepted Solution

    I think you've got the best solution already then.

    I think you're only other option is to hide the main form instead of closing it so the application doesn't quit.

    Featured Post

    Courses: Start Training Online With Pros, Today

    Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

    Join & Write a Comment

    Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
    More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now