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

  • SEARCH
  • Home
  • 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 68k
  • Answers 68k
  • 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 :g/xxxx/d This will delete all the lines with pattern, and… May 11, 2026 at 12:15 pm
  • added an answer Using your example, the solution is simple: bool DoOrTimeout<T>(T method,… May 11, 2026 at 12:15 pm
  • added an answer If Facebook's own avatar is also not showing, its a… May 11, 2026 at 12:15 pm

Related Questions

I have a .NET 2.0 WinForms application with a ToolStrip on my main form.
In WinForms, I can design a form and have a TabValue to control which
In VB.NET, I have a Combobox on a WinForm form. The form allows the
I have a WinForms application with a DataGridView control and a column of DataGridViewButtonCell
I have a winforms application that normally is at about 2-4% CPU. We are
I have a winforms application that presently ships with a chm file for context-sensitive
I have a WinForms app written in C# with .NET 3.5. It runs a
I have a WinForms application with a view where the user selects a single
I have a WinForms TreeView with one main node and several sub-nodes. How can
I have a Winforms application created in Visual Studio 2005 Pro, it connects to

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.