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

Windows Form

Scheduled Pinned Locked Moved C#
csharphelpquestionworkspace
4 Posts 3 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.
  • F Offline
    F Offline
    faisal khanani
    wrote on last edited by
    #1

    I have come across with a little problem that must be simpler for you guys; As a matter of fact, i m new in .Net/C# environment, hence i m facing a little bit difficulty in writing code. I have a form (Non-MDI); on its next button after successfull execution of a method i have to open a new form and for doing this i have written the following code: DBSecurity.DBSecurity msecure=new DBSecurity.DBSecurity(strServer,strUser,strPwd,strDatabase); if (msecure.Generate(txtCompany.text,txtLocation.Text)==true) { SecurityGUI.frmGUI frm=new frmGUI(); frm.ShowDialog(); this.Close(); } this code works fine as far as frmGUI form opening is concerned but it do not close the existing form and it still open on back. Am i writing wrong code? or do you have another solution?

    U P 2 Replies Last reply
    0
    • F faisal khanani

      I have come across with a little problem that must be simpler for you guys; As a matter of fact, i m new in .Net/C# environment, hence i m facing a little bit difficulty in writing code. I have a form (Non-MDI); on its next button after successfull execution of a method i have to open a new form and for doing this i have written the following code: DBSecurity.DBSecurity msecure=new DBSecurity.DBSecurity(strServer,strUser,strPwd,strDatabase); if (msecure.Generate(txtCompany.text,txtLocation.Text)==true) { SecurityGUI.frmGUI frm=new frmGUI(); frm.ShowDialog(); this.Close(); } this code works fine as far as frmGUI form opening is concerned but it do not close the existing form and it still open on back. Am i writing wrong code? or do you have another solution?

      U Offline
      U Offline
      uGue
      wrote on last edited by
      #2

      Hi, in the .NET documentation about the Form class ShowDialog() method it says this: "You can use this method to display a modal dialog box in your application. When this method is called, the code following it is not executed until after the dialog box is closed." That means that the behaviour you describe is wanted. It's not a bug, it's a feature ;) Try the Show() method. That could be your solution. Regards, Udo

      1 Reply Last reply
      0
      • F faisal khanani

        I have come across with a little problem that must be simpler for you guys; As a matter of fact, i m new in .Net/C# environment, hence i m facing a little bit difficulty in writing code. I have a form (Non-MDI); on its next button after successfull execution of a method i have to open a new form and for doing this i have written the following code: DBSecurity.DBSecurity msecure=new DBSecurity.DBSecurity(strServer,strUser,strPwd,strDatabase); if (msecure.Generate(txtCompany.text,txtLocation.Text)==true) { SecurityGUI.frmGUI frm=new frmGUI(); frm.ShowDialog(); this.Close(); } this code works fine as far as frmGUI form opening is concerned but it do not close the existing form and it still open on back. Am i writing wrong code? or do you have another solution?

        P Offline
        P Offline
        Polis Pilavas
        wrote on last edited by
        #3

        Try hiding your "parent" form instead and re-show it when you're done with the "child" (frmGUI) one:

        SecurityGUI.frmGUI frm = new frmGUI();
        this.Hide();
        frm.ShowDialog();
        this.Show();

        This will work fine since after closing the child form, the applications' control will return to the line that immediately follows the ShowDialog() method. Regards, Polis Can you practice what you teach?

        F 1 Reply Last reply
        0
        • P Polis Pilavas

          Try hiding your "parent" form instead and re-show it when you're done with the "child" (frmGUI) one:

          SecurityGUI.frmGUI frm = new frmGUI();
          this.Hide();
          frm.ShowDialog();
          this.Show();

          This will work fine since after closing the child form, the applications' control will return to the line that immediately follows the ShowDialog() method. Regards, Polis Can you practice what you teach?

          F Offline
          F Offline
          faisal khanani
          wrote on last edited by
          #4

          thanks Poils, It works fine.

          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