I know that here are quite a few similar questions to this one, but some of them are in VB or the answer does not work for my code. So here it is:
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
if(e.ColumnIndex == 7)
{
double cellvalue = new double();
double totalkcal = new double();
double totalpret = new double();
double.TryParse(dataGridView1[e.ColumnIndex - 1, e.RowIndex].Value.ToString(), out cellvalue);
double.TryParse(dataGridView1[e.ColumnIndex - 3, e.RowIndex].Value.ToString(), out totalkcal);
double.TryParse(dataGridView1[e.ColumnIndex - 4, e.RowIndex].Value.ToString(), out totalpret);
textBox5.Text = totalkcal.ToString();
}
}
What's wrong with it? I get the error in the title whenever the cell is clicked.
Thanks a lot !