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. how to address the situation of closing the form

how to address the situation of closing the form

Scheduled Pinned Locked Moved C#
tutorialquestion
6 Posts 4 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.
  • P Offline
    P Offline
    prasadbuddhika
    wrote on last edited by
    #1

    when the user try to close the form by clicking the close button of the title bar.how can show a dialog box to verify the form closing ?

    S 1 Reply Last reply
    0
    • P prasadbuddhika

      when the user try to close the form by clicking the close button of the title bar.how can show a dialog box to verify the form closing ?

      S Offline
      S Offline
      sujithkumarsl
      wrote on last edited by
      #2

      you will get form closing event @ that time

      My small attempt...

      P 1 Reply Last reply
      0
      • S sujithkumarsl

        you will get form closing event @ that time

        My small attempt...

        P Offline
        P Offline
        prasadbuddhika
        wrote on last edited by
        #3

        in witch event ? the closed or closing event ?

        M G 2 Replies Last reply
        0
        • P prasadbuddhika

          in witch event ? the closed or closing event ?

          M Offline
          M Offline
          MickCurley
          wrote on last edited by
          #4

          Its on your form closing event, you need to add code to cancel/continue..I presume something like the following. private void FormClosing(object sender, CancelEventArgs e) { if (MessageBox.Show("Are you sure you want to exit?", "Confirm exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { e.Cancel = true; } }

          A craft is an enemy if not well learned.

          P 1 Reply Last reply
          0
          • M MickCurley

            Its on your form closing event, you need to add code to cancel/continue..I presume something like the following. private void FormClosing(object sender, CancelEventArgs e) { if (MessageBox.Show("Are you sure you want to exit?", "Confirm exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { e.Cancel = true; } }

            A craft is an enemy if not well learned.

            P Offline
            P Offline
            prasadbuddhika
            wrote on last edited by
            #5

            thanks

            1 Reply Last reply
            0
            • P prasadbuddhika

              in witch event ? the closed or closing event ?

              G Offline
              G Offline
              Giorgi Dalakishvili
              wrote on last edited by
              #6

              Why don't you try it yourself? Or have a look at documentation? There is no chance of canceling the process if one of the events has already been fired. (Guess which one it is)

              #region signature my articles #endregion

              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