I've noticed an oddity with the using of a DataGrid component.
If I've got the DataGrid set to have a DataSource of a DataTable that has more than one row in it and I've focused on one of these rows (say row 9 of 10).
If I then empty my DataTable (using dt.Clear() I then get a problem wirh the Repaint method behind the DataGrid in question when I make an entry in the underlying DataTable such that I have one row in the grid.
The CurrentCell.RowIndex / CurrentRowIndex still maintains the last row position (namely 8) so obviously I get an error when it trys to deal with the DataGrid's row 8. In this case I get a very nasty red cross through the DataGrid that is trying to be repainted.
I've worked around this by resetting the CurrentRowIndex to 0 when I empty the DataTable behind the DataGrid.
Can anyone suggest why I should need to do this ?
If I have no rows in the DataGrid then how can my CurrentRowIndex be 8 still ???
Any thoughts would be appreciated.
Thanks in advance
Steve
If I've got the DataGrid set to have a DataSource of a DataTable that has more than one row in it and I've focused on one of these rows (say row 9 of 10).
If I then empty my DataTable (using dt.Clear() I then get a problem wirh the Repaint method behind the DataGrid in question when I make an entry in the underlying DataTable such that I have one row in the grid.
The CurrentCell.RowIndex / CurrentRowIndex still maintains the last row position (namely 8) so obviously I get an error when it trys to deal with the DataGrid's row 8. In this case I get a very nasty red cross through the DataGrid that is trying to be repainted.
I've worked around this by resetting the CurrentRowIndex to 0 when I empty the DataTable behind the DataGrid.
Can anyone suggest why I should need to do this ?
If I have no rows in the DataGrid then how can my CurrentRowIndex be 8 still ???
Any thoughts would be appreciated.
Thanks in advance
Steve