DataGridView / Enter Key?

I am using vb.net 2008 and DataGridView. I am looking for code that will allow me to move the key enterto the next column on the right, rather than navigate one row while remaining in the same column.

+3
source share
2 answers

Here is a CodeProject article that shows what you want to do:

Cheating DataGridView

This is C #, but it is also quite simple.

The approach discussed in this article is to subclass the DataGridView to override the ProcessDialogKey event to handle the logic for selecting the next cell on the same row or to wrap the first column on the next row.

Most approaches to accomplish what you want to do seem to include a subclass of DataGridView.

+4

, CellEndEdit. , ProcessDialogKey. . :

public class dgv : DataGridView
{
    protected override bool ProcessDialogKey(Keys keyData)
    {
        Keys key = (keyData & Keys.KeyCode);
        if (key == Keys.Enter)
        {
            return this.ProcessRightKey(keyData);
        }
        return base.ProcessDialogKey(keyData);
    }
    protected override bool ProcessDataGridViewKey(KeyEventArgs e)
    {
        if (e.KeyCode == Keys.Enter)
        {
            return this.ProcessRightKey(e.KeyData);
        }
        return base.ProcessDataGridViewKey(e);
    }
}
+6

Source: https://habr.com/ru/post/1723055/


All Articles