469,934 Members | 1,874 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,934 developers. It's quick & easy.

Changes to cells in DataGrid

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,
--
Tom Tempelaere.
Nov 16 '05 #1
7 2055
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

Nov 16 '05 #2
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 news:DC**********************************@microsof t.com...
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,
--
Tom Tempelaere.


Nov 16 '05 #3
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

"tomi" wrote:
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

Nov 16 '05 #4
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 [C# / .NET MVP]" wrote:
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 news:DC**********************************@microsof t.com...
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,
--
Tom Tempelaere.


Nov 16 '05 #5
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 news:56**********************************@microsof t.com...
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 [C# / .NET MVP]" wrote:
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
news:DC**********************************@microsof t.com...
> 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,
> --
> Tom Tempelaere.



Nov 16 '05 #6
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 [C# / .NET MVP]" wrote:
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 news:56**********************************@microsof t.com...
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 [C# / .NET MVP]" wrote:
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
news:DC**********************************@microsof t.com...
> 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,
> --
> Tom Tempelaere.


Nov 16 '05 #7
> 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)" <_|\|_0$P@|/\|titi____AThotmailD.Tcom|/\|@P$0_|\|_>
wrote in message news:76**********************************@microsof t.com... 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 [C# / .NET MVP]" wrote:
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
news:56**********************************@microsof t.com...
> 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 [C# / .NET MVP]" wrote:
>
>> 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
>> news:DC**********************************@microsof t.com...
>> > 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,
>> > --
>> > Tom Tempelaere.
>>
>>



Nov 16 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Ariel Gimenez | last post: by
reply views Thread by JochenZ | last post: by
4 posts views Thread by Glenn Owens | last post: by
4 posts views Thread by EMW | last post: by
2 posts views Thread by Luis Esteban Valencia | last post: by
3 posts views Thread by tshad | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.