Updating Cells in a datagrid

ianajones25

Member
Joined
Jan 3, 2007
Messages
9
Programming Experience
Beginner
Hi there, I hope someone can help.

In my app I have a datagrid called tblExpenditureDataGridView. In there I have numerous columns but what I want to do is that whenever a cell/row is changed two of the cells/columns (net and vat) should be added together and the result put in Gross.

The way i've tried is running an update query in the "cell click" and "cellLeave" statements but they don't seem to work.

I was wondering if there was a way to do this without having to resort to a query.

Many Thanks
 
You should have the DataTable upon which the DGV is based, do this instead. Take a look at the .Expression property of a DataColumn..
 
Hi cjard.

I've found where you set the expression in the dataset view but cannot fathom out how to structure the expression.

It's in a table called tblIncome with the three fields in question being Net,Vat and Gross and I want to add Net and Vat together and put it in Gross whenever Net or Vat are changed.

Is therre a guide to the formating of these statements.

Many thanks.
 
I forgot to mention: When I type [Net] + [Vat] as the expression it generates the error:

The column mapping from SourceColumn 'Gross' failed because the DataColumn 'Gross' is a computed column.

whenever I try to load up the table.
 
Back
Top