Dealing with no longer valid CurrentCell
Hi,
I have several virtual grids (v 2.1.0.9) in my project which often has the number of rows change. After the row changes I can be left with a CurrentCell which no longer exists. So, for example, if the CurrentCell is row 15, column 3 and the row count is changed to 10, the current cell is still at row 15 which no longer exists. I had expected for the current cell to correct itself, but since it hasn''t - what is the best way for handling the issue? Should I manually validate my CurrentCell every time I retrieve it, or is there an event / override method I can catch to correct the current cell when the row or column count renders it no longer valid?
Thanks,
Sue
SIGN IN To post a reply.
3 Replies
SH
Sue Harris
February 24, 2005 06:43 AM UTC
Ok, I''ve done a bit more looking and I''m more confused. I found the HasCurrentCell property which seems to nicely indicate whether the CurrentCell is valid (which it doesn''t appear to be after a row count change) - but then I realised that there are two properties CurrentCell and CurrentCellInfo. So now my question becomes, if I''m only interested in knowing the row/column of the current cell which should I look at?
Thanks
SH
Sue Harris
March 2, 2005 04:06 AM UTC
Unfortunately the HasCurrentCell doesn''t always work - in the instance where I click on a button on a form (and the grid loses focus), the grid always returns false for that property (and also in the case I''m investigating for HasCurrentCellInfo). So back to the original problem - what is the correct way to determine whether the grid has a (valid) current cell?
AD
Administrator
Syncfusion Team
March 2, 2005 10:03 AM UTC
You are handling QueryRowCount to provide the row count dynamically, correct?
If so. in that handler you can check the cuurentcell. (This is normally not a big performance hit as this event is only raised when a ResetVolatileData is done, and the value is otherwise cached. So, if you are just scrolling or moving the grid, this code shuld not be hit.) You do have to avoid a recursive call though as call CurrentCell.MoveTo to trigger QueryRowCount.
bool isInQueryRowCount = false;
private void gridControl1_QueryRowCount(object sender, GridRowColCountEventArgs e)
{
GridCurrentCell cc = this.gridControl1.CurrentCell;
if(cc.RowIndex > rowCount && !isInQueryRowCount)
{
isInQueryRowCount = true;
cc.MoveTo(rowCount, cc.ColIndex);
isInQueryRowCount = false;
}
e.Count = rowCount;
e.Handled = true;
}
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
SH Sue Harris
- Feb 24, 2005 04:13 AM UTC
- Mar 2, 2005 10:03 AM UTC