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

Scrolling to a non-visible cell in a GridDataBoundGrid

I'm working with a GridDataBoundGrid and I have a graph that is showing the same data as a plot. When a user clicks on a graph Point, that is translated to the corresponding grid cell.

I wanted to determine if this cell is currently visible in my GridDataBoundGrid, and if not, scroll to it so it is visible. The solution, though difficult to find in the KnowledgeBase and Forum, was actually pretty simple. I am posting here to share this code in case others also find this helpful:

if ( _lastHilite != oldHilite ) // hilite changed
{
GridRangeInfo test= GridRangeInfo.Cell(_lastHilite.X, _lastHilite.Y);

GridRangeInfo gri = this._gridControl.ViewLayout.VisibleCellsRange;
bool visible = gri.Contains ( test );

if ( ! visible )
{
this._gridControl.ScrollCellInView ( test );
}
}
this._gridControl.Refresh(); // force a repaint

1 Reply

HA haneefm Syncfusion Team April 9, 2007 09:33 AM UTC

Hi Steve,

You should call the Refresh() method before calling ScrollCellInView method and should turn ON the pixel scrolling of the grid by setting XScrollPixel to true. Please try the suggestion and let me know if this helps.

this._gridControl.VScrollPixel = true;
this._gridControl.HScrollPixel = true;

if ( _lastHilite != oldHilite ) // hilite changed
{
GridRangeInfo test= GridRangeInfo.Cell(_lastHilite.X, _lastHilite.Y);

GridRangeInfo gri = this._gridControl.ViewLayout.VisibleCellsRange;
bool visible = gri.Contains ( test );

this._gridControl.Refresh(); // force a repaint
if ( ! visible )
{
this._gridControl.ScrollCellInView ( test );
}
}

Best regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon