I have two data in two different datagrides, I want to take the value from the row, for me to count on the euclidien distance formula. I can take the value in the second datagridview, but I can't get the data in the first datagridview.
i was try to write foreach, but i still over there
foreach (DataGridViewRow row1 in dataGridView1.Rows)
{
foreach (DataGridViewRow row in dataGridView2.Rows)
{
double NilaiPixelGrid1 = Convert.ToDouble(row1.Cells[2].Value.ToString());
double NilaiRedGrid1 = Convert.ToDouble(row1.Cells[3].Value.ToString());
double NilaiGreenGrid1 = Convert.ToDouble(row1.Cells[4].Value.ToString());
double NilaiBlueGrid1 = Convert.ToDouble(row1.Cells[5].Value.ToString());
double NilaiPixel = Convert.ToDouble(row.Cells[2].Value.ToString());
double NilaiRed = Convert.ToDouble(row.Cells[3].Value.ToString());
double NilaiGreen = Convert.ToDouble(row.Cells[4].Value.ToString());
double NilaiBlue = Convert.ToDouble(row.Cells[5].Value.ToString());
double dist = Math.Pow((NilaiPixelGrid1 - NilaiPixel), 2) +
Math.Pow((NilaiRedGrid1 - NilaiRed), 2) +
Math.Pow((NilaiGreenGrid1 - NilaiGreen), 2) +
Math.Pow((NilaiBlueGrid1 - NilaiBlue), 2);
}
}
System.NullReferenceException: 'Object reference not set to an instance of an object.'