Here is the simple trick to get selected value in DataGridView in C#
object value = dataGridView1.Rows[e.Cell.RowIndex].Cells[3].FormattedValue;
object value1 = dataGridView1.Rows[e.Cell.RowIndex].Cells[4].FormattedValue;
object GSTPercentage = dataGridView1.Rows[e.Cell.RowIndex].Cells[5].FormattedValue;
if (value == "" || value1 == "" || GSTPercentage == "")
return;
double result = Convert.ToDouble(value);
double result1 = Convert.ToDouble(value1);
double resultGST = Convert.ToDouble(GSTPercentage);
double NetValue = (result * result1) * resultGST;
dataGridView1.Rows[e.Cell.RowIndex].Cells[6].Value = Convert.ToString(NetValue);
object value = dataGridView1.Rows[e.Cell.RowIndex].Cells[3].FormattedValue;
object value1 = dataGridView1.Rows[e.Cell.RowIndex].Cells[4].FormattedValue;
object GSTPercentage = dataGridView1.Rows[e.Cell.RowIndex].Cells[5].FormattedValue;
if (value == "" || value1 == "" || GSTPercentage == "")
return;
double result = Convert.ToDouble(value);
double result1 = Convert.ToDouble(value1);
double resultGST = Convert.ToDouble(GSTPercentage);
double NetValue = (result * result1) * resultGST;
dataGridView1.Rows[e.Cell.RowIndex].Cells[6].Value = Convert.ToString(NetValue);
Comments
Post a Comment