0

I'd like to invoke an event from unknown control in code. I'd love to do the following, but the "KeyDown" property is only for adding or removing (+= -=) events, not for invoking...

private void QBDT_KeyDown(object sender, KeyEventArgs e)
{
    Control l_oActiveControl = this.ActiveControl;
    if (l_oActiveControl is TextBox)
    {
        TextBox l_tbActive = l_oActiveControl as TextBox;
        if (e.KeyCode == Keys.C || e.KeyCode == Keys.Z || e.KeyCode == Keys.X || e.KeyCode == Keys.A)
        {
            l_oActiveControl.KeyDown(sender, e); 
            return;
        }
    }
    //Do Something
}

Any ideas? Thanks :)

Salih Karagoz
  • 2,189
  • 2
  • 22
  • 35
Amit Lipman
  • 687
  • 7
  • 19
  • 2
    Why are you trying to send the event to the control? are you just trying to send only those letters to the text box? it might be easier to just append the text to the textbox instead of trying to forward a event like that. – Scott Chamberlain Jul 18 '17 at 13:45
  • Check out these questions: https://stackoverflow.com/questions/27507946/pass-keydown-event-to-other-control https://stackoverflow.com/questions/3841178/how-to-call-an-event-manually-in-c – default locale Jul 18 '17 at 13:46

0 Answers0