0
votes

In a WPF Datagrid, how to detect when the user press the key "Tab" from the last cell/row ? With KEY_DOWN event the selected cell is unknown, with FOCUS_OUT we don't know the key pressed.

2

2 Answers

1
votes
    private void dataGrid1_PreviewKeyDown(object sender, KeyEventArgs e)
    {
        if (e.Key == Key.Tab)
        {
            MessageBox.Show("now tab!!!");//Here u know the tab press
            MessageBox.Show(dataGrid1.SelectedIndex.ToString());//Here u know the cell/row!
        }
    }
0
votes

You want to handle the PreviewKeyDown event on the DataGrid itself. Within the handler you can then check to see which cell is currently selected.