Skip to main content Skip to footer

Scrolling Multiple Spread Controls Simultaneously

This blog is an addition to the customized features of Spread for Winforms, where it implements synchronized scrolling of multiple Spread controls, both horizontally and vertically. Basic logic behind the implementation is very simple and checks for the scrollbar position of the Source Spread control. Scrollbar position for the source Spread is set for other Spread controls on the form using the properties SetViewPortTopRow() and SetViewPortLeftColumn(). These properties can be defined in the Spread events, TopChange and LeftChange which fires for vertical and horizontal scroll changes respectively. To describe the implementation, this blog example uses two Spreads on a form where scrolling the first Spread FpSpread1 , scrolls the second Spread FpSpread2 along with it. You can get the vertical scroll bar changed position in FpSpread1’s TopChanged event by using e.NewTop argument property. This event fires every time you scroll Spread vertically. This new top position given by e.NewTop will become the new top position for FpSpread2’s vertical scroll bar. See the code block below.

private void fpSpread1_TopChange(object sender, FarPoint.Win.Spread.TopChangeEventArgs e)  
{  
   fpSpread2.SetViewportTopRow(0,e.NewTop);  
}

Similarly, horizontal scroll bar changed position can be retrieved in Spread’s LeftChanged event by using e.NewLeft. This event fires every time you scroll Spread horizontally. Assign this new left position to left position of FpSpread2’s horizontal scroll bar as well. The code used is as follows:

private void fpSpread1_LeftChange(object sender, FarPoint.Win.Spread.LeftChangeEventArgs e)  
{  
   fpSpread2.SetViewportLeftColumn(0,e.NewLeft);  
}

Download the attached samples for complete demonstration. Download Sample VB Download Sample CS

MESCIUS inc.

comments powered by Disqus