how to move cell rows back to top of the grid

Posted by: cmdolcet69 on 8 September 2017, 2:48 pm EST

  • Posted 8 September 2017, 2:48 pm EST

    I have a grid that has 500 points (pre loaded) on it. I have deleted row 2 and after the deletion that row the grid goes all the way down to Row 499. How can I get it to go back up to Row 1?
  • Replied 8 September 2017, 2:48 pm EST

    Hello,

    I was not able to replicate the issue at my end. As soon as I delete a row in Spread, the grid remains at the same position to show the first row. I have created a sample depicting the same, kindly have a look at it. Please let me know if I am missing something. 

    If you still face the same issue, I would request you to provide me a sample depicting your issue so that I can debug it further. I would also like to know which version and build of Spread are you currently using.

    Thanks,

    Manpreet Kaur.


    2011/11/deletion.zip
  • Replied 8 September 2017, 2:48 pm EST

    I was not able to open your project example in my VS 2005. I have attached the code below that I am using. Also please note that I automatically set the row amount to 500 so when the user jumps to this screen the grid is already populated with the row.

     

      If Me.GridSpread.ActiveSheet.SelectionCount > 0 Then
                intSelectedCount = Me.GridSpread.ActiveSheet.Models.Selection.LeadRow - Me.GridSpread.ActiveSheet.Models.Selection.AnchorRow + 1
                If intSelectedCount < 0 Then
                    intSelectedCount = Me.GridSpread.ActiveSheet.Models.Selection.AnchorRow - Me.GridSpread.ActiveSheet.Models.Selection.LeadRow + 1
                    intLeadRow = Me.GridSpread.ActiveSheet.Models.Selection.AnchorRow
                    intEndRow = Me.GridSpread.ActiveSheet.Models.Selection.LeadRow
                    intActiveRow = intEndRow
                Else
                    intLeadRow = Me.GridSpread.ActiveSheet.Models.Selection.LeadRow
                    intEndRow = Me.GridSpread.ActiveSheet.Models.Selection.AnchorRow
                End If


                For intloop = intActiveRow To intActiveRow + intSelectedCount - 1
                    For intloop2 = 0 To Me.GridSpread.ActiveSheet.RowCount - 1
                        Me.GridSpread.ActiveSheet.SetActiveCell(intloop, 0)
                        Me.GridSpread.ActiveSheet.SetActiveCell(intloop2, 2)
                        GageID_Removed = GridSpread.ActiveSheet.ActiveCell.Text
                    Next
                Next

                Me.GridSpread.ActiveSheet.RemoveRows(intActiveRow, intSelectedCount)
                Me.GridSpread.ActiveSheet.ClearSelection()
     

  • Replied 8 September 2017, 2:48 pm EST

    Hello,


    I would suggest you to use the ShowRow method of Spread to always show the first row, once you delete any row from the grid. You can call this method once you have deleted the row or rows. So, you can add the following line of code at the end of the piece of code provided by you, this would always make the first row to show up, after the deletion of any row.


                          Me.GridSpread.ShowRow(0, 0, FarPoint.Win.Spread.VerticalPosition.Top)


    Hope it will help you. Please let me know if you have any queries further.


    Thanks,


    Manpreet Kaur.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels