datagrid dynamic total row

  • Thread starter Thread starter Jon
  • Start date Start date
J

Jon

I have a datagrid with a total row on the bottom. What is the best
method to "instantly" update the total row when the value of any row
changes. I am running into problems when I use the column changed
event to calculate the total and assign it directly to the grid ->
myDataGridObject[totalrow,colIdx]=newTotal. When I do this, more
change events are fired, causing unwanted consequences.
 
Jon,

What I would do is place an if statement around the code that updates
the data grid, updating the total row only if the value that changed was not
the total row itself.

Hope this helps.
 
The if statement is no problem. I guess the issue is that I am
updating the total row with a call to my datagrid object, ie
myDataGrid[totalRowIdx,curCol]=totalValue. The issue is that this
then triggers recursive calls to the columnchanging event and I get
lost in la la land. The crux of the question is, in what event should
do the calculation, and to what should I assign the new value -> the
datagrid or the underlying dataview structure...

Nicholas Paldino said:
Jon,

What I would do is place an if statement around the code that updates
the data grid, updating the total row only if the value that changed was not
the total row itself.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Jon said:
I have a datagrid with a total row on the bottom. What is the best
method to "instantly" update the total row when the value of any row
changes. I am running into problems when I use the column changed
event to calculate the total and assign it directly to the grid ->
myDataGridObject[totalrow,colIdx]=newTotal. When I do this, more
change events are fired, causing unwanted consequences.
 
Back
Top