public class GridSelectionControllerExt:GridSelectionController { SfDataGrid sfGrid; public GridSelectionControllerExt(SfDataGrid dataGrid):base(dataGrid) { sfGrid = dataGrid; } protected override void ProcessKeyDown(KeyEventArgs args) { var rowIndex = this.sfGrid.SelectionController.CurrentCellManager.CurrentRowColumnIndex.RowIndex; var colIndex = this.sfGrid.SelectionController.CurrentCellManager.CurrentRowColumnIndex.ColumnIndex; if(args.Key==Key.Enter || args.Key== Key.Tab) { if (colIndex == 0) { this.sfGrid.SelectionController.MoveCurrentCell(new RowColumnIndex(rowIndex, 2)); App.Current.Dispatcher.BeginInvoke(new Action(() => { this.sfGrid.SelectionController.CurrentCellManager.BeginEdit();
}), DispatcherPriority.ApplicationIdle); args.Handled = true; } } base.ProcessKeyDown(args); } |
protected override void ProcessKeyDown(KeyEventArgs args) { var rowIndex = this.sfGrid.SelectionController.CurrentCellManager.CurrentRowColumnIndex.RowIndex; var colIndex = this.sfGrid.SelectionController.CurrentCellManager.CurrentRowColumnIndex.ColumnIndex; if(args.Key==Key.Enter || args.Key== Key.Tab && !this.sfGrid.IsAddNewIndex(rowIndex)) { if (colIndex == 0) { this.sfGrid.SelectionController.MoveCurrentCell(new RowColumnIndex(rowIndex, 2)); App.Current.Dispatcher.BeginInvoke(new Action(() => { this.sfGrid.SelectionController.CurrentCellManager.BeginEdit();
}), DispatcherPriority.ApplicationIdle); args.Handled = true; } if(colIndex==2) { var viewModel = this.sfGrid.DataContext as ViewModel; var record = new StoreList("Magazine", true, "Johnson"); viewModel.CategoryCombo.Add("Magazine"); viewModel.StoreLists.Add(record); colIndex = 0; rowIndex = this.sfGrid.ResolveToRowIndex(record); this.sfGrid.SelectionController.MoveCurrentCell(new RowColumnIndex(rowIndex,colIndex));
App.Current.Dispatcher.BeginInvoke(new Action(() => { this.sfGrid.SelectionController.CurrentCellManager.BeginEdit(); }), DispatcherPriority.ApplicationIdle); args.Handled=true; return; } } base.ProcessKeyDown(args); |