473,326 Members | 2,133 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

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 2233
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: JochenZ | last post by:
Hello, I have a DataGrid(View) and a DataTable. The DataTable is displayed in the DataGridView: dataGridView.DataSource = theTable; The user is allowed to select some rows and then the...
1
by: Alex | last post by:
Hi all... I have a DataGrid bound to a DataTable. My DataTable gets updated programmatically as it contains the status of a number of worker threads. Each "main" worker thread launches a...
5
by: Ariel Gimenez | last post by:
Morning! After several hours breaking my mind, finally my code works, but i think is trash-code, can someone tellme how is the correct way to access the value of my cells within a datagrid?... in...
0
by: JochenZ | last post by:
Hello, I have a DataGrid(View) and a DataTable. The DataTable is displayed in the DataGridView. The user is allowed to select some rows and then the following snippet updates some values in the...
4
by: Glenn Owens | last post by:
I have a DataGrid web control which I've dynamically populated with template columns to be used for bulk-editting. Generally, all of the columns are textbox and/or dropdownlist child controls. ...
4
by: EMW | last post by:
For my ASP.NET program I want to use the datagrid as a sort of planning tool. Based on the information in a XML file, a cell of the datagrid must show an image... Well, this is what I would...
2
by: Luis Esteban Valencia | last post by:
Hello I have a datagrid with a dropdownlist that has the products, another column has the price of the product and when the user changes the product it also must change the price how can I achieve...
3
by: tshad | last post by:
How do I get blank cells to show in my dataGrid? I am databinding to my datagrid, but any cells that are blank, don't show. Normally, you would put an &nbsp in the cell to make IE display the...
0
by: cwbp17 | last post by:
I'm having trouble updating individual datagrid cells. Have two tables car_master (columns include Car_ID, YEAR,VEHICLE) and car_detail (columns include Car_ID,PRICE,MILEAGE,and BODY);both tables...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.