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. Windows Forms
  4. How to handle form's ControlBox's Close Button

How to handle form's ControlBox's Close Button

Scheduled Pinned Locked Moved Windows Forms
helptutorial
6 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.
  • P Offline
    P Offline
    pashitech
    wrote on last edited by
    #1

    Hi, I have to excute my own functionality while closing the windows form. but its always firing formclosing event (I can not use formclosing event as I am using this to navigate to other forms) Finally, Please help me to solve, how to excute functionality of MyOwn Button while closing using ControlBox's X Button Thanks, Prashanth

    G 1 Reply Last reply
    0
    • P pashitech

      Hi, I have to excute my own functionality while closing the windows form. but its always firing formclosing event (I can not use formclosing event as I am using this to navigate to other forms) Finally, Please help me to solve, how to excute functionality of MyOwn Button while closing using ControlBox's X Button Thanks, Prashanth

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

      Call MyOwn Button's event handler in formclosing event.

      Giorgi Dalakishvili #region signature my articles #endregion

      P 1 Reply Last reply
      0
      • G Giorgi Dalakishvili

        Call MyOwn Button's event handler in formclosing event.

        Giorgi Dalakishvili #region signature my articles #endregion

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

        Thanks for your help Mr.Giorgi Dalakishvili, But that won't solve my Problem, See, I am not using MDI. I have Main Form which contains Exit,Form1 and few other buttons, and my functionality to close the application is written in exit button. But when user clicks any other button say,Form1 to go Form1, Since The Main Forms Close event also calling at that time the Main Form too closing not my application(So all the threads and timers that I wrote in exit button are not ending) I just want to know how to call my exit button functinality Only when user clicks ControlBox's X Button. Thanks,For ur Time Pashi

        G 1 Reply Last reply
        0
        • P pashitech

          Thanks for your help Mr.Giorgi Dalakishvili, But that won't solve my Problem, See, I am not using MDI. I have Main Form which contains Exit,Form1 and few other buttons, and my functionality to close the application is written in exit button. But when user clicks any other button say,Form1 to go Form1, Since The Main Forms Close event also calling at that time the Main Form too closing not my application(So all the threads and timers that I wrote in exit button are not ending) I just want to know how to call my exit button functinality Only when user clicks ControlBox's X Button. Thanks,For ur Time Pashi

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

          Your post is quite unclear but from what I guess that when you click Form1, your main form is closing. Why do you do that? Just show Form1.

          Giorgi Dalakishvili #region signature my articles #endregion

          P 1 Reply Last reply
          0
          • G Giorgi Dalakishvili

            Your post is quite unclear but from what I guess that when you click Form1, your main form is closing. Why do you do that? Just show Form1.

            Giorgi Dalakishvili #region signature my articles #endregion

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

            Thanks Again For your reply, say I am in Main Form Now. After I click on Form1 Button of Main Form, Main Form's Closing event is calling and since the in the ControlBox 'X' Button is also calling Main Form's Closing event for Main form the application is closing. So, I just want to know do I have any alternate so that, I can catch the form Closing Event I mean whether the process is entering into form closing event by ControlBox's 'X' click or while redirecting to any other form. Hope you got my point now! Thanks again for ur time

            prashanth, s/w Engineer, Syfnosys.

            L 1 Reply Last reply
            0
            • P pashitech

              Thanks Again For your reply, say I am in Main Form Now. After I click on Form1 Button of Main Form, Main Form's Closing event is calling and since the in the ControlBox 'X' Button is also calling Main Form's Closing event for Main form the application is closing. So, I just want to know do I have any alternate so that, I can catch the form Closing Event I mean whether the process is entering into form closing event by ControlBox's 'X' click or while redirecting to any other form. Hope you got my point now! Thanks again for ur time

              prashanth, s/w Engineer, Syfnosys.

              L Offline
              L Offline
              Lutoslaw
              wrote on last edited by
              #6

              Maybe a CloseReason property of a FormClosingEventArgs object which passed by a Closing event is what are you looking for.

              Greetings - Gajatko Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.

              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