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

Scroll two grids at the same time

I have two grids obe below the other. When the horizontal scroll bar on one grid scrolls the other grid should move the exact same amount (and vice versa). Do you have code snippet for this.

1 Reply

AD Administrator Syncfusion Team April 11, 2005 04:22 AM

Handle the LeftColChanged event in each grid. Here is a handler that illustrates what you need to do. The idewas is to set the other grid''s LeftColIndex when the a grid''s LeftColIndex is changed. You ahve to avoid a recursive call though, and that is why the inEvent member is used.
bool inEvent = false;
private void grid_LeftColChanged(object sender, GridRowColIndexChangedEventArgs e)
{
	if(inEvent)
		return;
	inEvent = true;
	GridControl grid = sender as GridControl;
	if(grid != this.gridControl1)
	{
		this.gridControl1.LeftColIndex = grid.LeftColIndex;
	}
	if(grid != this.gridControl2)
	{
		this.gridControl2.LeftCollndex = grid.LeftColIndex;
	}
	inEvent = false;
}

Loader.
Live Chat Icon For mobile
Up arrow icon