C# 1.1 DataGrid question

J

Jason Huang

Hi,

In my C# 1.1 windows form project, I have a form Form1 which has a DataGrid
DataGrid1.
In the DataGrid1, I have 3 columns, they are Unit, UnitPrice, TotalPrice.
What I want is in this DataGrid, if a user modify the Unit or UnitPrice,
then the value of the column TotalPrice will respond returning the value of
Unit * UnitPrice, after the user press the button.
I tried in the KeyPress event but I have encountered some problem,
if the Unit origin value is 8 ,and a user typed in 9, the event get the
value 8 , not 9.
What event do I need to use to get the value of 9 or I need to do extra
manipulation in the KeyPress event?
Thanks for help.


Jason
 
S

Som Nath Shukla

hi use this thsi is cell click event when after updating unit or unit price u
will click the row again u will get the updated value

private void dataGridView2_CellClick(object sender,
DataGridViewCellEventArgs e)
{
dataGridView2.Rows[e.RowIndex].Cells[2].Value =
Convert.ToInt32(dataGridView2.Rows[e.RowIndex].Cells[0].Value) *
Convert.ToInt32(dataGridView2.Rows[e.RowIndex].Cells[1].Value);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top