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


    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.


    Manpreet Kaur.

  • 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
                    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

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

  • Replied 8 September 2017, 2:48 pm EST


    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.

                          <FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas>Me</FONT></FONT></FONT><FONT size=2 face=Consolas><FONT size=2 face=Consolas>.GridSpread.ShowRow(0, 0, FarPoint.Win.Spread.</FONT></FONT><FONT color=#2b91af size=2 face=Consolas><FONT color=#2b91af size=2 face=Consolas><FONT color=#2b91af size=2 face=Consolas>VerticalPosition</FONT></FONT></FONT><FONT size=2 face=Consolas><FONT size=2 face=Consolas>.Top</FONT></FONT><FONT size=2 face=Consolas><FONT size=2 face=Consolas>)</FONT></FONT>

    <FONT size=2 face=Consolas><FONT size=2 face=Consolas>Hope it will help you. Please let me know if you have any queries further.</FONT></FONT>

    <FONT size=2 face=Consolas><FONT size=2 face=Consolas>Thanks,</FONT></FONT>

    <FONT size=2 face=Consolas><FONT size=2 face=Consolas>Manpreet Kaur.

Need extra support?

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

Learn More

Forum Channels