Guest User

Untitled

a guest
Jun 21st, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. public void ScrollToRow(int theRow)
  2. {
  3. //
  4. // Expose the protected GridVScrolled method allowing you
  5. // to programmatically scroll the grid to a particular row.
  6. //
  7. if (DataSource != null)
  8. {
  9. GridVScrolled(this, new ScrollEventArgs(ScrollEventType.LargeIncrement, theRow));
  10. }
  11. }
  12.  
  13. // Get current user scroll position
  14. int scrollPosition = myGridView.FirstDisplayedScrollingRowIndex;
  15.  
  16. // Do some work
  17. ...
  18.  
  19. // Rebind the grid and reset scrolling
  20. myGridView.DataBind;
  21. myGridView.FirstDisplayedScrollingRowIndex = scrollPosition;
  22.  
  23. public void ScrollToRow(int theRow)
  24. {
  25. //
  26. // Expose the protected GridVScrolled method allowing you
  27. // to programmatically scroll the grid to a particular row.
  28. //
  29. if (DataSource != null)
  30. {
  31. GridVScrolled(this, new ScrollEventArgs(ScrollEventType.LargeIncrement, theRow));
  32. }
  33. }
  34.  
  35. Public Sub ScrollToRow(ByVal theRow As Integer)
  36. '
  37. ' Expose the protected GridVScrolled method allowing you
  38. ' to programmatically scroll the grid to a particular row.
  39. '
  40. On Error Resume Next
  41.  
  42. If Not DataSource Is Nothing Then
  43. GridVScrolled(Me, New ScrollEventArgs(ScrollEventType.LargeIncrement, theRow))
  44. End If
  45. End Sub
  46.  
  47. int v= dataGridView1.VerticalScrollingOffset ;
  48. int h= dataGridView1.HorizontalScrollingOffset ;
  49. //...reload
  50. dataGridView1.VerticalScrollingOffset = v;
  51. dataGridView1.HorizontalScrollingOffset =h;
  52.  
  53. int indexOfTopMostRow = HitTest(dataGrid.RowHeaderWidth + 10,
  54. dataGrid.PreferredRowHeight + 10).Row;
  55.  
  56. if(gridEmployees.FirstDisplayedScrollingRowIndex != -1) gridEmployees.FirstDisplayedScrollingRowIndex = 0;
Add Comment
Please, Sign In to add comment