private void dvItemGrid_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) { if (dvItemGrid.Columns[e.ColumnIndex].Name == "ItemID") { string strItemID = e.FormattedValue.ToString(); if (strItemID == "") { MessageBox.Show("Item ID cannot be blank."); dvItemGrid.CurrentCell = this.dvItemGrid.Rows[e.RowIndex].Cells[e.ColumnIndex]; return; } } } private void dvItemGrid_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { e.SuppressKeyPress = true; int iColumn = dvItemGrid.CurrentCell.ColumnIndex; int iRow = dvItemGrid.CurrentCell.RowIndex; if (iColumn == dvItemGrid.ColumnCount - 1) dvItemGrid.CurrentCell = dvItemGrid[1, iRow - 1]; else dvItemGrid.CurrentCell = dvItemGrid[iColumn + 1, iRow]; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)