Visual c++ forms keydown events not responding

so i added the keydown even to my form in order to try it but nothing happens when i click any of the buttons, i didnt forget to enable the key preview option but still no hope here is the code:

private: System::Void Form3_KeyDown( Object^ /*sender*/, System::Windows::Forms::KeyEventArgs^ e )
{
    if ( e->KeyCode == Keys::F1 )
    {
        textBox2->Text="Hey";
    }
    if ( e->KeyCode == Keys::Return )
    {
        textBox2->Text="Hey";
    }
    if ( e->KeyCode == Keys::E )
    {
        textBox2->Text="Hey";
    }
    if ( e->KeyCode == Keys::Shift )
    {
        textBox2->Text="Hey";
    }
    if ( e->KeyCode == Keys::NumPad0 )
    {
        textBox2->Text="Hey";
    }
    if ( e->KeyCode == Keys::Down )
    {
        textBox2->Text="Hey";
    }
}

Any help?

Upvotes: 0

Views: 2840

Answers (1)

gavurin
gavurin

Reputation: 21

Set the Form KeyPreview property to True.

Upvotes: 2

Related Questions