I want to check values in grid columns when performing multiplication between Quantity and Price values. I have done this and it works perfectly!
But I have a problem when I enter a string value in column Quantity or after I edit the column and leave it empty. I am getting an error:
So how can I check the values and when the user types string, char or blank input, show a MessageBox
with feedback?
Here is my code:
private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
int price, quantity, total;
quantity= int.Parse(dataGridView1.Rows[e.RowIndex].Cells["Quantity"].Value.ToString());
cena = int.Parse(dataGridView1.Rows[e.RowIndex].Cells["Price"].Value.ToString());
total = quantity * price ;
dataGridView1.Rows[e.RowIndex].Cells["Total"].Value = total;
}
When I enter an integer everything works OK...