Okay I have a problem with my Windows Application. My DataGridView consists of the following columns: ProductName, Qty, Price, Subtotal. So I am assuming that the Cell Indexes of these are respectively as follows: 0, 1, 2, 3. However, whenever I try executing the code below:
txtSubtotalProducts.Text = "Php " + (Convert.ToDouble(dgvProducts.Rows[0].Cells[3].Value) +
Convert.ToDouble(dgvExpenses.Rows[1].Cells[3].Value) +
Convert.ToDouble(dgvExpenses.Rows[2].Cells[3].Value)).ToString();
However, whenever I run this code block, I bump into this error message: Index Out of Range.
Am I missing anything in here? Thanks alot in advance.
EDITED: Sorry, index 4 was actually something I tried, but originally, I am trying both 2 and 3 as indexes without any luck. However, when I try 1 (which is the Qty column) it works perfectly.