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. Image for the cookie policy date
close icon

Grid Control CurrentCell not reset when RowCount = 0

Hi -
I have a situation where the only row of a GridControl is removed using Rows.RemoveRange and the CurrentCell object is still representing a cell in that row (which was the current cell when the row was removed). This is causing problems in our code in keypress events (where the rowindex and columnindex are still set to that cell) as well as the CurrentCellChanged event which is firing (see my attached screenshot). The Renderer is null so i can check for that in the event, but i'm wondering if there's something that can be done to null out the CurrentCell so that the events don't fire.

I don't know if this is a bug or due to something i'm doing in code. It's present in both versions 5.2 (VS2005) and 7.4 (VS2008).
Thanks,
Julie





CurrentCell_NoRows_1751ae93.zip

3 Replies

CI Christopher Issac Sunder K Syncfusion Team May 28, 2010 02:38 PM UTC

Hi Julie,

Thank you for your interest in Syncfusion products.

While removing the rows using RemoveRange() method, the current cell renderer cannot get refreshed and notifies the old indexes. Hence, we can make use of MoveTo() method after removing the range to force the current cell to refresh.

Here is the code snippet regarding this,

this.gridControl1.Rows.RemoveRange(0, this.gridControl1.RowCount);
if (this.gridControl1.RowCount == 0)
{
this.gridControl1.CurrentCell.MoveTo(0, 0, GridSetCurrentCellOptions.SetFocus); //refresh the current cell

}

Please refer the following sample which illustrates the above.

http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=F946821951706273.zip

Please let me know if you have any further concerns.

Regards,
Christopher K.


JL Julie Levy June 1, 2010 09:42 PM UTC

Thanks. That worked.


CI Christopher Issac Sunder K Syncfusion Team June 2, 2010 04:42 AM UTC

Hi Julie,

Thank you for the update.

We are glad to hear this.

Thank you for using Syncfusion products.

Regards,
Christopher K.

Loader.
Live Chat Icon For mobile
Up arrow icon