Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Override ProcessCmdKey C#

Tags:

c#

winforms

I have code that overrides the TextBox ProcessCmdKey method:

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
    switch (keyData)
    {
        case: //something to do etc etc.
    }
    return true;
}

But when I use the above code, I can't write in the TextBox. Is there a solution for this?

like image 853
Damian Bala Avatar asked Dec 21 '22 00:12

Damian Bala


1 Answers

Once you've handled everything, pass it on to the base control:

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
    switch (keyData)
    {
        case /* whatever */:
        // ...
        default:
            return base.ProcessCmdKey(ref msg, keyData);
    }

    return true;
}
like image 156
Ry- Avatar answered Dec 23 '22 12:12

Ry-