只能模拟这样的效果,滚动条的位置会有些差异:
- public partial class MainPage : UserControl
- {
- int rows, cols; // i 表示能滚动的最后一行, j 表示能滚动的最后一列
- public MainPage()
- {
- InitializeComponent();
-
- this.gcSpreadSheet1.ShowActiveCell(GrapeCity.Windows.SpreadSheet.UI.VerticalPosition.Top, GrapeCity.Windows.SpreadSheet.UI.HorizontalPosition.Left);
- gcSpreadSheet1.ScrollBarTrackPolicy = GrapeCity.Windows.SpreadSheet.UI.ScrollBarTrackPolicy.Both;
- gcSpreadSheet1.SizeChanged += new SizeChangedEventHandler(gcSpreadSheet1_SizeChanged);
- gcSpreadSheet1.TopRowChanged += new EventHandler<GrapeCity.Windows.SpreadSheet.UI.ViewportEventArgs>(gcSpreadSheet1_TopRowChanged);
- gcSpreadSheet1.LeftColumnChanged += new EventHandler<GrapeCity.Windows.SpreadSheet.UI.ViewportEventArgs>(gcSpreadSheet1_LeftColumnChanged);
- }
- void gcSpreadSheet1_SizeChanged(object sender, SizeChangedEventArgs e)
- {
- rows = this.gcSpreadSheet1.GetViewportBottomRow(this.gcSpreadSheet1.GetActiveRowViewportIndex()) + 1;
- cols = this.gcSpreadSheet1.GetViewportRightColumn(this.gcSpreadSheet1.GetActiveColumnViewportIndex()) + 1;
- }
- void gcSpreadSheet1_LeftColumnChanged(object sender, GrapeCity.Windows.SpreadSheet.UI.ViewportEventArgs e)
- {
- if (gcSpreadSheet1.GetViewportRightColumn(gcSpreadSheet1.ActiveSheetIndex) == gcSpreadSheet1.ActiveSheet.ColumnCount-1)
- {
- gcSpreadSheet1.SetViewportLeftColumn(this.gcSpreadSheet1.GetActiveColumnViewportIndex(), gcSpreadSheet1.ActiveSheet.ColumnCount - cols);
- }
- }
- void gcSpreadSheet1_TopRowChanged(object sender, GrapeCity.Windows.SpreadSheet.UI.ViewportEventArgs e)
- {
- if (gcSpreadSheet1.GetViewportBottomRow(gcSpreadSheet1.ActiveSheetIndex) == gcSpreadSheet1.ActiveSheet.RowCount - 1)
- {
- gcSpreadSheet1.SetViewportTopRow(this.gcSpreadSheet1.GetActiveRowViewportIndex(), gcSpreadSheet1.ActiveSheet.RowCount - rows);
- }
- }
- }
复制代码 |