What I want to do is to change value of row's forth cell if cell number 3 is changed. I have an EditEnding method for my grid. That's my method below. I don't really know how to finish it
that's the grid definition:
<DataGrid x:Name="dataGrid1"... CellEditEnding="dataGrid1_EditEnding">
and the method:
private void dataGrid1_EditEnding(object sender, DataGridCellEditEndingEventArgs e)
{
// initializing DataRowView from my datagrid
DataRowView drv = (DataRowView)dataGrid1.CurrentItem;
// checking if there were any changes
if (drv.Row[3, DataRowVersion.Original] != drv.Row[3])
{
//set value to cell
}
}
do not edit the datagridrow - edit the underlying object in wpf!
this mean when the bound property to cell 3 is changed then do your changes to the property bound to cell 4. INotifyPropertyChanged will notify your grid and will show your changes
If you already have logic to calculate cell4 value when cell3 is changed, then when property binded to column 3 is changed you should call INotifyPropertyChanged of property binded to column 3 & 4.
Well, i did my stuff, just forget to post it here.
First I did it with EditEnding event, it looked like that:
The problem was it was adding the value only on second edit. Then I changed my idea and added a RowChanged event to my DataTable, which was like that:
The method was going into infinity loop (it was noticing, that fourth row had changed).
And then i saw this: http://www.windowsdevcenter.com/pub/a/dotnet/2003/05/26/datacolumn_expressions.html
I've ended with one line long code:
@blindmeis, I forgott to mention I use ADO.NET, sorry