locked
MenuItem AddHandler question RRS feed

  • Question

  • OK, here goes...

    I'm trying to build a general-purpose procedure for building a MenuStrip on any page in my Windows Forms application.  I make a call to this sub in my forms' Load event and pass in 'Me'.  Based on the form, it then adds the MenuStrip and various MenuItems.  Each MenuItem comes with the requisite event handler.

    In these events, I typically open a new form, and I want to close the form that called it.  This is where I'm having my problem.  I can't figure out how to determine which form is calling the event so I can close that form.  If I use System.Windows.Forms.Form.ActiveForm.Close(), the form I just opened is immediately closed (because it's now the active form, I presume).

    Can anyone help me to solve this?  If I haven't been clear about anything, let me know and I'll clarify.

    Many thanks!

    Monday, July 23, 2012 3:30 PM

Answers

  • Whose the sender?  Which form is the MenuStrip on?  Isn't that the form you want to close?  Close the MenuStrip's Parent.
    Monday, July 23, 2012 3:42 PM