I have a grid view of type data grid view text box column.
There are following fields in the grid.
Sr.No | Description | HSNCode | Qty | Rate | Amount
The Sr.No and the Amount is generated in the program.
My problem is that when I am using tab
key for navigating through the grid, I want to check that the is "Qty" and "Rate" contains any value or not.
i.e. if the user enters the description then without entering "Qty" and "Rate" one jumps to the Amount field where I am generating the value by "Qty * Rate" but I want to check if the "Rate" or "Qty" is not entered then I want to transfer the control over either of them.
I have found the solution which works for the mouse click, the code is as below:
private void grdData_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == 5)
{
if (Convert.ToString(grdData.Rows[e.RowIndex].Cells[4].Value).Equals(""))
{
grdData.ClearSelection();
grdData.Rows[e.RowIndex].Cells[4].Selected = true;
}
}
}
This works perfectly when user clicks on the Amount field, but what if I want the same solution for tab key
.
How can I find the solution? Which event should I use for grid.?
Please help