Changes to cells in DataGrid

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi there,

I'm struggling to get the right event. I want to be notified of a change in
a cell in a DataGrid made by a user. I need following information about the
change:
* the row index
* the column index
* the newly entered value

I need this information to update another DataGrid. I have checked the
following events, but they don't supply the info I need:

* DataGrid.CurrentCellChanged: Yields the row/col-index of the newly entered
cell.
* DataTable.ColumnChanged/RowChanged: Does not yield the indices of the row
or the column of the cell that changed.

Can someone help me?

Best regards and thanks,
 
CurrentCell Changed returns values of currently entering cell (row,
column, value)
Either you can react on this event (by storing information about
previously entered cell) or you can also use event Validate (this event
fires when grids property validate is set on true and when leaving some
cell.

But the easiest way to do this, i think, is to store info in temp
Variables.

i.e.
tempX = -1; tempY = -1; temValue = null;
(enter Cell) finds out that x,y = -1 .. -> beginning of evaluation ->
copy values of x,y,value to tempX,tempY ....
(enter other Cell) do actions with tempX,tempY ...... copy info to
tempX,tempY

This all can be implemented as your own event, but most of this is done
by event VALIDATE.

Hope this answers your question.

Tomi
 
Hi Tom,

Bind both grids to the same datasource and they will get in sync
automatically.
 
Hey Tomi,

The grid does _not_ receive _any_ validated or validating event, even though
the CausesValidation property is set to true.

If only it were so simple :)

TT
 
Dmitriy,

Is is not so simplistic. The other DataGrid contains a single column, and
each row contains the maximum value of the corresponding row in the first
DataGrid. There is no 'mutual' data source. The second grid is computed from
the entries in the first. Actually I only really need the row index of the
changed cell to do this.

Thanks,
Tom T.

Dmitriy Lapshin said:
Hi Tom,

Bind both grids to the same datasource and they will get in sync
automatically.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

TT (Tom Tempelaere) said:
Hi there,

I'm struggling to get the right event. I want to be notified of a change
in
a cell in a DataGrid made by a user. I need following information about
the
change:
* the row index
* the column index
* the newly entered value

I need this information to update another DataGrid. I have checked the
following events, but they don't supply the info I need:

* DataGrid.CurrentCellChanged: Yields the row/col-index of the newly
entered
cell.
* DataTable.ColumnChanged/RowChanged: Does not yield the indices of the
row
or the column of the cell that changed.

Can someone help me?

Best regards and thanks,
 
Then I'd subscribe to the events generated by the datasource itself,
recompute the aggregate values upon receiving such an event and update them
in the 'bogus' datasource the second grid is bound to.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

TT (Tom Tempelaere) said:
Dmitriy,

Is is not so simplistic. The other DataGrid contains a single column, and
each row contains the maximum value of the corresponding row in the first
DataGrid. There is no 'mutual' data source. The second grid is computed
from
the entries in the first. Actually I only really need the row index of the
changed cell to do this.

Thanks,
Tom T.

Dmitriy Lapshin said:
Hi Tom,

Bind both grids to the same datasource and they will get in sync
automatically.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"TT (Tom Tempelaere)" <_|\|_0$P@|/\|titi____AThotmailD.Tcom|/\|@P$0_|\|_>
wrote in message
Hi there,

I'm struggling to get the right event. I want to be notified of a
change
in
a cell in a DataGrid made by a user. I need following information about
the
change:
* the row index
* the column index
* the newly entered value

I need this information to update another DataGrid. I have checked the
following events, but they don't supply the info I need:

* DataGrid.CurrentCellChanged: Yields the row/col-index of the newly
entered
cell.
* DataTable.ColumnChanged/RowChanged: Does not yield the indices of the
row
or the column of the cell that changed.

Can someone help me?

Best regards and thanks,
 
Dmitriy,

I've tried that, but the sad thing is that the event-args of these events
have a DataRow member or DataColumn member. It is not possible to get the row
index of the changed row which is rather sad.

The DataRowChangeEventArgs contains a Row (type DataRow) property but does
not give the index of the row in the DataTable.

The DataColumnChangeEventArgs contains the same Row property, and a Column
property (DataColumn). The index of the data-column can be retrieved but I
don't need it.

If I'm not mistaking, there is no way to get the index of the changed row in
the underlying DataTable with the changed/changing events of DataSource class.

BTW: What do you mean by 'bogus'? Do you mean that is should not be
programmed the way I did?

Thanks,
Tom Tempelaere.

Dmitriy Lapshin said:
Then I'd subscribe to the events generated by the datasource itself,
recompute the aggregate values upon receiving such an event and update them
in the 'bogus' datasource the second grid is bound to.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

TT (Tom Tempelaere) said:
Dmitriy,

Is is not so simplistic. The other DataGrid contains a single column, and
each row contains the maximum value of the corresponding row in the first
DataGrid. There is no 'mutual' data source. The second grid is computed
from
the entries in the first. Actually I only really need the row index of the
changed cell to do this.

Thanks,
Tom T.

Dmitriy Lapshin said:
Hi Tom,

Bind both grids to the same datasource and they will get in sync
automatically.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"TT (Tom Tempelaere)" <_|\|_0$P@|/\|titi____AThotmailD.Tcom|/\|@P$0_|\|_>
wrote in message
Hi there,

I'm struggling to get the right event. I want to be notified of a
change
in
a cell in a DataGrid made by a user. I need following information about
the
change:
* the row index
* the column index
* the newly entered value

I need this information to update another DataGrid. I have checked the
following events, but they don't supply the info I need:

* DataGrid.CurrentCellChanged: Yields the row/col-index of the newly
entered
cell.
* DataTable.ColumnChanged/RowChanged: Does not yield the indices of the
row
or the column of the cell that changed.

Can someone help me?

Best regards and thanks,
 
I've tried that, but the sad thing is that the event-args of these events
have a DataRow member or DataColumn member. It is not possible to get the
row
index of the changed row which is rather sad.

Do you really need the index? If you just need to recompute the aggregate
values, you need only a fact that the original data source has changed?
Maybe you could elaborate on that and we would invent a workaround?
BTW: What do you mean by 'bogus'? Do you mean that is should not be
programmed the way I did?

Nope, I might have used an improper word. What I was trying to say is you
had two data sources - one with actual data, and the other containing
calculated aggregate values. I called the second one 'bogus' because it was
a kind of artificial, you could have stored the calculated values in an
array or elsewhere, if the DataGrid would allow to be bound to an array
without a hassle. But as DataGrid can be usually bound only to a DataTable,
you have to have a specially constructed DataTable to store the aggregate
values - at least this is how I understood your architecture.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

TT (Tom Tempelaere) said:
Dmitriy,

I've tried that, but the sad thing is that the event-args of these events
have a DataRow member or DataColumn member. It is not possible to get the
row
index of the changed row which is rather sad.

The DataRowChangeEventArgs contains a Row (type DataRow) property but does
not give the index of the row in the DataTable.

The DataColumnChangeEventArgs contains the same Row property, and a Column
property (DataColumn). The index of the data-column can be retrieved but I
don't need it.

If I'm not mistaking, there is no way to get the index of the changed row
in
the underlying DataTable with the changed/changing events of DataSource
class.

BTW: What do you mean by 'bogus'? Do you mean that is should not be
programmed the way I did?

Thanks,
Tom Tempelaere.

Dmitriy Lapshin said:
Then I'd subscribe to the events generated by the datasource itself,
recompute the aggregate values upon receiving such an event and update
them
in the 'bogus' datasource the second grid is bound to.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"TT (Tom Tempelaere)" <_|\|_0$P@|/\|titi____AThotmailD.Tcom|/\|@P$0_|\|_>
wrote in message
Dmitriy,

Is is not so simplistic. The other DataGrid contains a single column,
and
each row contains the maximum value of the corresponding row in the
first
DataGrid. There is no 'mutual' data source. The second grid is computed
from
the entries in the first. Actually I only really need the row index of
the
changed cell to do this.

Thanks,
Tom T.

:

Hi Tom,

Bind both grids to the same datasource and they will get in sync
automatically.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"TT (Tom Tempelaere)"
<_|\|_0$P@|/\|titi____AThotmailD.Tcom|/\|@P$0_|\|_>
wrote in message
Hi there,

I'm struggling to get the right event. I want to be notified of a
change
in
a cell in a DataGrid made by a user. I need following information
about
the
change:
* the row index
* the column index
* the newly entered value

I need this information to update another DataGrid. I have checked
the
following events, but they don't supply the info I need:

* DataGrid.CurrentCellChanged: Yields the row/col-index of the newly
entered
cell.
* DataTable.ColumnChanged/RowChanged: Does not yield the indices of
the
row
or the column of the cell that changed.

Can someone help me?

Best regards and thanks,
 
Back
Top