private void grid1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { if ( grid1.CurrentCell.ColumnIndex == 3) { TextBox tb = (TextBox)e.Control; tb.TextChanged += new EventHandler(tb_TextChanged); } if (grid1.CurrentCell.ColumnIndex == 5) { TextBox tb5 = (TextBox)e.Control; tb5.TextChanged += new EventHandler(tb5_TextChanged); } if (grid1.CurrentCell.ColumnIndex == 4) { TextBox tb4 = (TextBox)e.Control; tb4.TextChanged += new EventHandler(tb4_TextChanged); } }
tb5_TextChanged , tb4_TextChanged , tb3_TextChanged all same code
<pre>void tb5_TextChanged(object sender, EventArgs e) { var c5 = (sender as TextBox).Text; double No3 = 0; double No2 = 0; double No1 = 0; if (grid1.CurrentCell.ColumnIndex == 5) label8.Text = c5; if (grid1.CurrentCell.Value != null) { for (int i = 0; i < grid1.RowCount; i++) { if (grid1.Rows[i].Cells[0].Value.ToString() != null && grid1.Rows[i].Cells[1].Value.ToString() != null) { if (Double.TryParse(label6.Text, out No2) && Double.TryParse(label7.Text, out No1) && Double.TryParse(label8.Text, out No3)) grid1.Rows[i].Cells[6].Value = (No1 * No2 - No3).ToString(); } } } }
Convert.ToDouble
Double.TryParse
tb_TextChanged
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)