Moon
Moon

Reputation: 20012

C# DataGridView : override keydown events

i am working with DataGridView trying to provide specific utility to my user...

what i want to do is when some key is presses instead of the normal function that the key was supposed to perform like updown arrows and page up down keys etc i want to stop the default action

like when on a selected row, datagrid in selectfullrow, when down arrow is press it shouldn't change the row selection or goto the next row

Upvotes: 3

Views: 2579

Answers (1)

DevExpress Team
DevExpress Team

Reputation: 11376

You should handle the KeyDown event and set the e.Handled to true to disable the default action:

    private void dataGridView1_KeyDown(object sender, KeyEventArgs e) {
        e.Handled = e.KeyCode == Keys.Down;
    }

Upvotes: 4

Related Questions