Search code examples
c#eventskeypressmdi

Enable KeyDown Event only in active child of a MDI Application c#


I've a MDI application with a mainForm and a childForm with KeyPreview set to TRUE. Now in my childForm when I press a key, the program starts the event KeyPressed in both forms. Can I disable the event in the mainForm when the childForm is active?

What i want is thet: when the childForm is Active, only the event in the form should be triggered...

Best regards, Stefano


Solution

  • you could just add

    if(ActiveMdiChild != null)
      return;
    

    to the beginning of the event handler of the parent window...