We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Dealing with no longer valid CurrentCell

Thread ID:

Created:

Updated:

Platform:

Replies:

25303 Feb 24,2005 04:13 AM UTC Mar 2,2005 10:03 AM UTC Windows Forms 3
loading
Tags: GridControl
Sue Harris
Asked On February 24, 2005 04:13 AM UTC

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

Sue Harris
Replied On 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

Sue Harris
Replied On 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?

Administrator [Syncfusion]
Replied On 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;
}

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;