Hi .. I am new at c# . I am making an invoice generator . In it i am using dataGridView. Its a very new to me. GridView has 4 columns. Item, Quantity, PriceperItem and total. Values in 'item' clumn come from database. and user enters values of 'quantity' and 'priceperitem'. the total value should be automatically generted by calculating quantity*priceperitem when user click on 'yotal' column's cell. I have searched on google alottt but still wondering. I have done something like this but of no value. Kindly help me. Thanks in advance.
public void newFunc()
{
string val;
string val1;
int col = this.dataGridView1.CurrentCell.ColumnIndex;
if (col == 3)
{
val = this.dataGridView1.Columns[1].ToString();
val1 = this.dataGridView1.Columns[2].ToString();
int v = int.Parse(val);
int v1 = int.Parse(val1);
int v2 = v * v1;
this.dataGridView1.CurrentCell.Value = v2;
}
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
newFunc();
}