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. Form Closing Problem and MessageBox Independence [modified]

Form Closing Problem and MessageBox Independence [modified]

Scheduled Pinned Locked Moved C#
helptutorial
3 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
    mfcuser
    wrote on last edited by
    #1

    Maybe I have to use a form to do that rather than using a messagebox. It seems like a message box depends on the form it is being called. I do have a form where I have a line of code to call a dialog. From that dialog, I open another form. When the user click ok, I want the first form to close, however it does not close. here is what I am talking about for example, assume that my form is form 3, inside my form 3, I have a dialog to open form two. When the user clicks ok, form 2 will open where form 3 will close, however form 3 never closes inside form 3 I have if (dialogresponse == dialogresult.ok) form3.activeform.close(); then create an open form 2 The way to look at it, form 3 only close after form 2 open and close it does not work, it seems like I have to do that in another form. I don't want fo have a form for that only. Maybe I am missing something. -- modified at 20:02 Thursday 14th December, 2006

    G 1 Reply Last reply
    0
    • M mfcuser

      Maybe I have to use a form to do that rather than using a messagebox. It seems like a message box depends on the form it is being called. I do have a form where I have a line of code to call a dialog. From that dialog, I open another form. When the user click ok, I want the first form to close, however it does not close. here is what I am talking about for example, assume that my form is form 3, inside my form 3, I have a dialog to open form two. When the user clicks ok, form 2 will open where form 3 will close, however form 3 never closes inside form 3 I have if (dialogresponse == dialogresult.ok) form3.activeform.close(); then create an open form 2 The way to look at it, form 3 only close after form 2 open and close it does not work, it seems like I have to do that in another form. I don't want fo have a form for that only. Maybe I am missing something. -- modified at 20:02 Thursday 14th December, 2006

      G Offline
      G Offline
      gnadeem
      wrote on last edited by
      #2

      Hi, are you using MDI interface style. if yes then try using ActiveMdiChild property. if not then see if your ActiveForm is not returning null reference. further if you are running this code inside form3, can you not simply call this.close(). Regards.

      M 1 Reply Last reply
      0
      • G gnadeem

        Hi, are you using MDI interface style. if yes then try using ActiveMdiChild property. if not then see if your ActiveForm is not returning null reference. further if you are running this code inside form3, can you not simply call this.close(). Regards.

        M Offline
        M Offline
        mfcuser
        wrote on last edited by
        #3

        I am not using MDI, my application is simply single document or single form. Also I already tried this.close but it does not work by the way this is the simple code DialogResult myMessage; messageResponse = MessageBox.Show("message", "title", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (myMessage== DialogResult.OK) { Form2 form2= new Form2(); form2.ShowDialog(); Form3.ActiveForm.Close();//this does not work here, it does not matter what form that I use }

        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