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. hide form using the close button

hide form using the close button

Scheduled Pinned Locked Moved C#
question
8 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.
  • M Offline
    M Offline
    Mridang Agarwalla
    wrote on last edited by
    #1

    How can i hide my form when the user clicks the Close (X) button? What should i write and under which event?

    R I 2 Replies Last reply
    0
    • M Mridang Agarwalla

      How can i hide my form when the user clicks the Close (X) button? What should i write and under which event?

      R Offline
      R Offline
      raheeli
      wrote on last edited by
      #2

      on form close event you have to write, this.hide(); Raheel Iqbal

      1 Reply Last reply
      0
      • M Mridang Agarwalla

        How can i hide my form when the user clicks the Close (X) button? What should i write and under which event?

        I Offline
        I Offline
        Ingo
        wrote on last edited by
        #3

        You should catch the FormClosing event (under Net 1.1 it's just calledc closing event I think): private void FormTest_FormClosing(object sender, FormClosingEventArgs e) { e.Cancel = true; this.Hide(); } Greetings, Ingo ------------------------------ A bug in a Microsoft Product? No! It's not a bug it's an undocumented feature!

        M 1 Reply Last reply
        0
        • I Ingo

          You should catch the FormClosing event (under Net 1.1 it's just calledc closing event I think): private void FormTest_FormClosing(object sender, FormClosingEventArgs e) { e.Cancel = true; this.Hide(); } Greetings, Ingo ------------------------------ A bug in a Microsoft Product? No! It's not a bug it's an undocumented feature!

          M Offline
          M Offline
          Mridang Agarwalla
          wrote on last edited by
          #4

          I've tried using your code but I'm a small problem - I'm using a notify icon class in my project and when i click the close button, my aplication exits instead of hiding.

          I 1 Reply Last reply
          0
          • M Mridang Agarwalla

            I've tried using your code but I'm a small problem - I'm using a notify icon class in my project and when i click the close button, my aplication exits instead of hiding.

            I Offline
            I Offline
            Ingo
            wrote on last edited by
            #5

            Well I don't know the nofiyicon class but I don't know if this changes somtehing. I tested my code again and my form isn't closed. I put a timer on the form and I'm able to show this form again. What does the NotifyIcon Class on your Form? Greetings, Ingo ------------------------------ A bug in a Microsoft Product? No! It's not a bug it's an undocumented feature!

            M 1 Reply Last reply
            0
            • I Ingo

              Well I don't know the nofiyicon class but I don't know if this changes somtehing. I tested my code again and my form isn't closed. I put a timer on the form and I'm able to show this form again. What does the NotifyIcon Class on your Form? Greetings, Ingo ------------------------------ A bug in a Microsoft Product? No! It's not a bug it's an undocumented feature!

              M Offline
              M Offline
              Mridang Agarwalla
              wrote on last edited by
              #6

              what an idiot I am. I totally forgot to add the e.cancel = true; My bad.

              I 1 Reply Last reply
              0
              • M Mridang Agarwalla

                what an idiot I am. I totally forgot to add the e.cancel = true; My bad.

                I Offline
                I Offline
                Ingo
                wrote on last edited by
                #7

                :) ------------------------------ A bug in a Microsoft Product? No! It's not a bug it's an undocumented feature!

                S 1 Reply Last reply
                0
                • I Ingo

                  :) ------------------------------ A bug in a Microsoft Product? No! It's not a bug it's an undocumented feature!

                  S Offline
                  S Offline
                  Saravanan_article
                  wrote on last edited by
                  #8

                  if i set e.cancel = true and this.hide() then the form will not closing..and still it is visible.. i wrote the code in formClosing Event.. Any ideas.. Regards, Saravanna

                  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