Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 153013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:43:32+00:00 2026-05-11T09:43:32+00:00

I have a WinForms form that won’t close. In OnFormClosing, e.Cancel is set to

  • 0

I have a WinForms form that won’t close. In OnFormClosing, e.Cancel is set to true. I am guessing that some object in my application has bound to the Closing or FormClosing event, and is blocking the close. To find out, I’d like to determine what delegates are bound to one of these events.

Is there a way to determine the list of handlers bound to an event? Ideally I would do this via the Visual Studio debugger, but can write code in the application to find the handlers if necessary. Understanding that an event is like a hidden private field, I’ve navigated through the Debugger to the ‘Non-Public Fields’ for the ‘Windows.Forms.Form’ ancestor of my form, but to no avail.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T09:43:33+00:00Added an answer on May 11, 2026 at 9:43 am

    In short, you’re not meant to do this – but for debugging purposes…

    An event is often backed by a private field – but not with controls; they use the EventHandlerList approach. You would have to access the form’s protected Events member, looking for the object mapped to the (private) EVENT_FORMCLOSING object.

    Once you have the FormClosingEventHandler, GetInvocationList should do the job.


    using System; using System.ComponentModel; using System.Reflection; using System.Windows.Forms; class MyForm : Form {     public MyForm()     { // assume we don't know this...         Name = 'My Form';         FormClosing += Foo;         FormClosing += Bar;     }      void Foo(object sender, FormClosingEventArgs e) { }     void Bar(object sender, FormClosingEventArgs e) { }      static void Main()     {         Form form = new MyForm();         EventHandlerList events = (EventHandlerList)typeof(Component)             .GetProperty('Events', BindingFlags.NonPublic | BindingFlags.Instance)             .GetValue(form, null);         object key = typeof(Form)             .GetField('EVENT_FORMCLOSING', BindingFlags.NonPublic | BindingFlags.Static)             .GetValue(null);          Delegate handlers = events[key];         foreach (Delegate handler in handlers.GetInvocationList())         {             MethodInfo method = handler.Method;             string name = handler.Target == null ? '' : handler.Target.ToString();             if (handler.Target is Control) name = ((Control)handler.Target).Name;             Console.WriteLine(name + '; ' + method.DeclaringType.Name + '.' + method.Name);         }     } } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 76k
  • Answers 76k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer You need 2 different callbacks, one for keydown and another… May 11, 2026 at 2:58 pm
  • added an answer IE (and maybe other browsers) doesn't cache URLs with any… May 11, 2026 at 2:58 pm
  • added an answer I doubt you'd want to be writing something like this… May 11, 2026 at 2:58 pm

Related Questions

I have a WinForms form that won't close. In OnFormClosing, e.Cancel is set to
I am creating a department picker form that is going to serve as a
This is a bit of a strange one, but I've been struggling for a
I started to make some thing in WPF and I have a question. I
I'm having some problems integrating MS MapPoint 2009 into my WinForms .Net 2.0 application

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.