Scrolling Multiple Spreads Simultaneously

We often come across a scenario where a large amount of data needs to be displayed in a grid and it is not completely visible in the browser's window; here the Scrolling functionality comes into play. We are allowed to scroll horizontally and vertically to view the data in a spreadsheet. So is the case with ComponentOne Spread. With Spread you can turn the scrolling feature off by using :

   gcSpreadSheet1.ScrollBarTrackPolicy = GrapeCity.Windows.SpreadSheet.UI.ScrollBarTrackPolicy.Off;  

By default, scrolling is enabled for all the sheets. In this blog I am going to show you how we can scroll two or more Spreads in a Silverlight application, simultaneously. This implementation can be very useful if you have a large amount of data. You can divide this data into two or more parts and show in different Spread controls. You can set the TopRow for each Spread instance to the new TopRow of the scrolled Spread in it's TopRowchanged event. For example:

void gcSpreadSheet1_TopRowChanged(object sender, GrapeCity.Windows.SpreadSheet.UI.ViewportEventArgs e)  
  gcSpreadSheet2.SetViewportTopRow(e.ViewportIndex, e.NewIndex);  

The above code will work fine for vertical scroll. Now if you want to implement this for horizontal scroll as well you may set the Left column for each Spread instance to the Left column of the scrolled Spread in its LeftColumnChanged event. For example:

void gcSpreadSheet1_LeftColumnChanged(object sender, GrapeCity.Windows.SpreadSheet.UI.ViewportEventArgs e)  
  gcSpreadSheet2.SetViewportLeftColumn(e.ViewportIndex, e.NewIndex);  

You can do this for as many spread instances as you want. and you can show all of them scrolling by scrolling one of them. Here's a demo of this : Please download the samples given below for demonstration. Download Sample C# Download Sample VB


GrapeCity Developer Tools
comments powered by Disqus