简体   繁体   中英

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

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;
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM