// Use ProcessCmdKey Befor Form_Load
// Set AllowUserToAdd Row To true
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == Keys.Enter)
{
int iCol = dtg.CurrentCell.ColumnIndex;
int iRow = dtg.CurrentCell.RowIndex;
if (iCol == dtg.Columns.Count - 1)
{
if (iRow == dtg.Rows.Count - 1)
{
dtg.Rows.Add("FirstValue","SecondValue"," . . .");
}
dtg.CurrentCell = dtg[0, iRow + 1];
}
else
{
dtg.CurrentCell = dtg[iCol + 1, iRow];
}
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}