Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. jumping from one form to another

jumping from one form to another

Scheduled Pinned Locked Moved C#
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    michael wikstrom
    wrote on last edited by
    #1

    I wish to jump from running the main form Form1 to run my Form2. I want my Form2 to dispose Form1 and continue to run as the main form. I have excperienced som difficulty in doing this as when Form1 is disposed it will close Form2 even if i have set the reference in Form1 to acces Form2 to be null. I believe its because Form1 is running the main thread, is it possible for me to create a similar thread in Form2 to overtake the main thread.

    H 1 Reply Last reply
    0
    • M michael wikstrom

      I wish to jump from running the main form Form1 to run my Form2. I want my Form2 to dispose Form1 and continue to run as the main form. I have excperienced som difficulty in doing this as when Form1 is disposed it will close Form2 even if i have set the reference in Form1 to acces Form2 to be null. I believe its because Form1 is running the main thread, is it possible for me to create a similar thread in Form2 to overtake the main thread.

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      Form1 is what the message pump is using to keep the loop alive so that it translates and dispatches messages throughout your application (Windows Forms just encapsulates Windows messaging and common controls). Disposing your form (or even closing it) stops the message pump. If you're desiging a wizard-like interface, you should consider having a single form that maintains state between forms as well as navigation between them. And instead of Form derivatives, you could actually use any container control such as a UserControl (easiest to design in VS.NET, if you like that sort of thing). There are several articles here on CodeProject that discuss this. If you want to create a new main window for your application, then you could try using Application.Run on your instance of Form2 then dispose Form1. I'm not sure how this would affect your application, however, since a new STA thread would be created for the new main window. Give it a try, though.

      Microsoft MVP, Visual C# My Articles

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups