private void GridTrxInvF_CellValueChanged_1(object sender, DataGridViewCellEventArgs e) { if (GridTrxInvF.CurrentCell != null && GridTrxInvF.CurrentCell.ColumnIndex == GridTrxInvF.Columns["displayQty"].Index && GridTrxInvF.CurrentCell.Value != null) { int col = GridTrxInvF.CurrentCell.ColumnIndex; int row = GridTrxInvF.CurrentCell.RowIndex; int nRows = GridTrxInvF.Rows.Count - 1; int nCol = GridTrxInvF.Columns.Count - 1; if (nCol == col && nRows == row) { GridTrxInvF.CurrentCell = GridTrxInvF[0, 0]; } else if (nRows == row) { GridTrxInvF.CurrentCell = GridTrxInvF[col + 1, 0]; } else { var row2 = GridTrxInvF.Rows[GridTrxInvF.RowCount - 1]; GridTrxInvF.CurrentCell = row2.Cells[1]; GridTrxInvF.CurrentCell.Selected = true; GridTrxInvF.BeginEdit(true); } } } protected override bool ProcessDataGridViewKey(System.Windows.Forms.KeyEventArgs e) { if (e.KeyCode == Keys.Escape) _CellEnteredFromEsc = true; else _CellEnteredFromEsc = false; int TimesToSend = 1; if (this.CurrentRow == null) return base.ProcessDataGridViewKey(e); else if (e.KeyCode == Keys.Enter) { if (this.CurrentCell.ColumnIndex == _Get_The_Last_Visibale_Index() && this.ValidateRequiredCellsInRow() && this.ValidateInRow() && this.CurrentCell.RowIndex == (this.Rows.Count - 1)) { this.AddNewRow(); } else { for (int i = this.CurrentCell.ColumnIndex + 1; i < this.Columns.Count; i++) { if (!this.Columns[i].Visible) continue; if (this.Columns[i].Tag != null && (this.Columns[i].Tag as ColumnTag).IsDisabled) { if (this[i, this.CurrentCell.RowIndex] == this[this.Columns.Count - 1, this.Rows.Count - 1] && this.ValidateRequiredCellsInRow() && this.ValidateInRow()) { this.AddNewRow(); return false; } else TimesToSend++; } else break; } if (!_StopCellTab) SendKeys.Send("{TAB " + TimesToSend + "}"); this._CellEnteredFromTab = true; } return false; } else if (bIsGridValid) return base.ProcessDataGridViewKey(e); return false; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)