private void CheckBox_PreviewKeyDown(object sender, KeyEventArgs e) { try { if (e.Key == Key.Space) { int rowselect = dgFunctions.SelectedIndex; CheckBox_Click(null, null); dgFunctions.Items.Refresh(); DataGridHelper.NVSFocus(dgFunctions, rowselect, 2); } } catch (Exception ex) { CommonData.log.Error(ex.ToString()); } }
/// <summary> /// forcus vào bản ghi (tên datagrid, dòng , cột) /// </summary> /// <param name="grid">tên grid</param> /// <param name="row">row muốn forcus</param> /// <param name="column">cột</param> public static void NVSFocus(this DataGrid grid, int row, int column) { try { DataGridCell _dgc = DataGridHelper.GetCell(grid, row, column); //grid.Items.Refresh(); if (_dgc != null) { _dgc.Focus(); grid.SelectedIndex = row; } else { _dgc.Focus(); grid.SelectedIndex = row; } } catch { } }
private void frmGroupUser_Right_Loaded(object sender, RoutedEventArgs e) { loaddata(); DataGridHelper.NVSFocus(dgFunctions, 0, 0); }