private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e) { // Display a grid of pdf, cdf... values from user's random variate x value. try { if (e.ColumnIndex == 0) { // Clicked on left-most random variate x column to enter a value. int i = e.RowIndex; string s = CDF_data.Rows[i].Cells[0].Value.ToString(); double x = double.Parse(s); // Get value of users random variate x. double pdf = dist.pdf(x); // Compute pdf values from x double cdf = dist.cdf(x); // & cdf double ccdf = dist.ccdf(x); // & complements. CDF_data.Rows[i].Cells[1].Value = pdf; // and display values. CDF_data.Rows[i].Cells[2].Value = cdf; CDF_data.Rows[i].Cells[3].Value = ccdf; } } catch (SystemException se) { MessageBox.Show("Error in random variable value: " + se.Message, "Calculation Error"); } }