Please help with DataGridViev . I need to have a table in 2 columns with the previously specified number of rows ( gg ). In the 1st column there should be numbers in order, and in the second temperature values by the formulas.
My attempt at solving below. In it, when you click the "fill table" button (button 4), the program crashes with the error:
A raw exception of type "System.FormatException" in mscorlib.dll
Additional information: The input string had the wrong format.
Code:
int gg = Convert.ToInt32(textBox2.Text); double z_pnd = Convert.ToDouble(textBox4.Text), z_pvd = Convert.ToDouble(textBox3.Text), t_kond = Convert.ToDouble(textBox8.Text), t_dear = Convert.ToDouble(textBox9.Text), t_oe = Convert.ToDouble(textBox10.Text), t_egu = Convert.ToDouble(textBox11.Text), z = Convert.ToDouble(textBox2.Text), alfa = 0.9, tp_pereddear = t_dear - 10, t_nach = Convert.ToDouble(textBox6.Text), p_pg = Convert.ToDouble(textBox7.Text), t_pv = ((t_nach - t_kond - t_oe - t_egu) / (z + 1)), t_pvopt = t_nach - t_pv, t_pvek = alfa * (t_pvopt - t_kond) + t_kond, delt_pvd = (t_pvek - t_dear) / z_pvd, delt_pnd = (tp_pereddear - t_kond - t_oe - t_egu) / z_pnd; double[] x = new double[gg]; double[] y = new double[gg]; for (int i = 0; i <= gg - 1; i++) { if (i == 0) { x[i] = 1; y[i] = (t_kond + t_oe + t_egu + t_pv); } else { y[0] = (t_kond + t_oe + t_egu + t_pv); x[i] = (i + 1); y[i] = (y[0] + t_pv*i); } { dataGridView1.Rows[i].Cells[0].Value = x[i].ToString(); dataGridView1.Rows[i].Cells[1].Value = y[i].ToString();
textBoxxxxmentioned in the code - at the time of execution ofbutton4_Click. - Igor