Click here to Skip to main content
15,902,817 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
 am creating windows application using c# 2010, here i am using data grid view for billing purpose, here i want, i am enter first cell values in below method and how to show multiplication result on second column

Ex :

first cell       second cell
10x10             100

how to create above method give me any one idea


What I have tried:

How to multiplication data grid view cell values
Posted
Updated 22-Jul-17 4:59am

See here: DataColumn.Expression Property[^] - it includes an example.
 
Share this answer
 
I would suggest you to use two different columns instead of single column, this will make data entry and even less complicated for implementation.

And then handle the CellEndEdit event of your gridview. And in that event calculate and assign the value to the third column

something like
private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
int quantity,rate;
if (int.TryParse(dataGridView1.Rows[e.RowIndex].Cells["quantity"].Value.ToString(), out quantity) && int.TryParse(dataGridView1.Rows[e.RowIndex].Cells["rate"].Value.ToString(), out rate))
{
int price = quantity * rate;
dataGridView1.Rows[e.RowIndex].Cells["price"].Value = price.ToString();
}
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900