0

I'm moving a Winforms app from VB to C#. I have a TrueDBGrid with a ContextMenuStrip thats pops up on a right click. When I don't handle the mnuContext Opening event the menu pops up. When I do handle the event the handler is called but the menu wont popup - even if the handler does nothing.

The code below has been trimmed to just have the handler call, so it's not what the code is doing, just the existence of the handler itself.

public void MenuOpeningHandler(object sender, System.ComponentModel.CancelEventArgs e)
{
    e.Cancel = false;
}

Setup code is:

public InvoiceListForm()
{
    InitializeComponent();

    mnuContext.Opening += MnuContext_Opening;
}

private void MnuContext_Opening(object sender, System.ComponentModel.CancelEventArgs e)
{
     MenuOpeningHandler(sender, e);
     e.Cancel = false;
}

The event appears to be stopped/Cancelled instead of continuing to propagate and open. Any idea what could be missing?

StayOnTarget
  • 11,743
  • 10
  • 52
  • 81
Craig
  • 517
  • 1
  • 9
  • 17
  • Well, since it usually works, it's something in your code. This event handler appears to be wired up in code (not created by the designer). See that you don't have something off where you're subscribing to it. What's that `.Cancel = false;`? Why did you post it? – Jimi Jul 16 '19 at 09:09
  • sorry should be e.Cancel - from a Microsoft sample. – Craig Jul 16 '19 at 09:12
  • subscribe code added – Craig Jul 16 '19 at 09:19

0 Answers0