4

I am using the SpreadsheetGear control. I would like to be able to get the position of the vertical scroll bar so that after a refresh of the control I can return users to the same set of rows they were viewing before the refresh.

The ScrollPositionChanged event is working just fine, but I'm not seeing any information in the WorkbookView object or the ScrollPositionChangedEventArgs object that tells me the current location of the scroll bar.

I'm also not seeing any way to set a value on the vertical scroll bar to reset it's location after the refresh.

I'm sure I'm being thick here. Thanks in advance.

Jay
  • 4,627
  • 1
  • 21
  • 30

1 Answers1

1

You can get the row position of the top row as you scroll by using the ScrollRow property of the WindowInfo object.

int rowPosition = workbookView1.ActiveWorksheet.WindowInfo.ScrollRow;

If you want workbookView to return to this position, you can use the Activate() method on a worksheet cell.

workbookView1.ActiveWorksheet.Cells[rowPosition, 0].Activate();
Daniel
  • 5,602
  • 4
  • 33
  • 36
  • Hi Dan, thank you for the answer. I'm looking to set the horizontal scroll position to the same column every time I open a new spreadsheet file. I changed your idea to: ActiveWorksheet.Cells(0, 22).Activate(). This does activate the column (I see it is selected). But the column is not scrolled into position. I tried: WorkbookView1.ActiveWorksheet.WindowInfo.ScrollColumn = 22. That sets column 22 to the left most position in the WorkbookView. But I can't scroll to see columns A-V. Also, I had to do GetLock and ReleaseLock. – CoolBreeze Apr 26 '19 at 18:26