G
Guest
I'm struggling with the lack of useful events provided by DataGrid and CurrencyManager. (Windows Forms, not Web Forms
Right now the problem I'm having is this
I have two DataGrids in a master-detail configuration. Edits to certain cells need to immediately (or at least upon changing focus to another row) update items displayed on a map. I would like to minimize refreshing the map because it may become a flicker and/or throughput issue with large numbers of items, i.e. I'd rather update the map only when relevant data has been edited, as opposed to updating any time DataGrid cell or row focus changes
The only way I can seem to catch a CurrencyManager ItemChanged event is if I hit enter in a cell after editing it. If I edit a cell and then leave by any other method (tab, arrow, click other cell, leave datagrid altogether, etc.), the data is updated but the ItemChanged event never fires. Furthermore, a majority of the detail data contains only one row for each master row, which means the enter key does nothing since there is no next row for it to move to! In this case only ctrl-enter will suffice. I'm also finding that the DataTable RowChanging and RowChanged events are equally unpredictable in this situation, again depending on how I exited the cell/row being edited in the DataGrid. The CurrentCellChanged event is useless because you've already left the previous cell before you can determine if its value changed. Perhaps in CurrentCellChanged I could store the cell coordinates to be used as a "previous" cell the next time the event fires, but that seems a little shaky. The only other workaround I can think of would involve intercepting every possible means of moving from one cell to another (all tab, arrow, enter, etc. keypresses, mouse clicks, etc.) to determine if a cell's value changed before losing focus. This also is obviously an ugly, shaky solution
Any suggestions
On a related note, I've already had to force an EndEdit on the current cell when the details DataGrid loses focus -- I found that if you edit a detail cell and then click on a master row without first hitting enter on the detail cell, the wrong master row gets updated with the new data! The master row you just clicked on to leave the detail DataGrid gets the data, rather than the master row you had previously selected allowing you to edit its details. I've stripped this down to just the bare essentials and I'm convinced it's an internal .NET bug.
Right now the problem I'm having is this
I have two DataGrids in a master-detail configuration. Edits to certain cells need to immediately (or at least upon changing focus to another row) update items displayed on a map. I would like to minimize refreshing the map because it may become a flicker and/or throughput issue with large numbers of items, i.e. I'd rather update the map only when relevant data has been edited, as opposed to updating any time DataGrid cell or row focus changes
The only way I can seem to catch a CurrencyManager ItemChanged event is if I hit enter in a cell after editing it. If I edit a cell and then leave by any other method (tab, arrow, click other cell, leave datagrid altogether, etc.), the data is updated but the ItemChanged event never fires. Furthermore, a majority of the detail data contains only one row for each master row, which means the enter key does nothing since there is no next row for it to move to! In this case only ctrl-enter will suffice. I'm also finding that the DataTable RowChanging and RowChanged events are equally unpredictable in this situation, again depending on how I exited the cell/row being edited in the DataGrid. The CurrentCellChanged event is useless because you've already left the previous cell before you can determine if its value changed. Perhaps in CurrentCellChanged I could store the cell coordinates to be used as a "previous" cell the next time the event fires, but that seems a little shaky. The only other workaround I can think of would involve intercepting every possible means of moving from one cell to another (all tab, arrow, enter, etc. keypresses, mouse clicks, etc.) to determine if a cell's value changed before losing focus. This also is obviously an ugly, shaky solution
Any suggestions
On a related note, I've already had to force an EndEdit on the current cell when the details DataGrid loses focus -- I found that if you edit a detail cell and then click on a master row without first hitting enter on the detail cell, the wrong master row gets updated with the new data! The master row you just clicked on to leave the detail DataGrid gets the data, rather than the master row you had previously selected allowing you to edit its details. I've stripped this down to just the bare essentials and I'm convinced it's an internal .NET bug.