Select a cell when ?error?

Posted by: zqonline on 8 September 2017, 1:41 pm EST

  • Posted 8 September 2017, 1:41 pm EST

      ex.ToString "System.IndexOutOfRangeException: Invalid row2 index: 1 (must be between 2 and 499)
       ? FarPoint.Win.Spread.Cells.get_Item(Int32 row, Int32 column, Int32 row2, Int32 column2)
       ? Spread_??.frm????.FpSpread1_SelectionChanged(Object sender, SelectionChangedEventArgs e) ?? E:\????\????\Spread\Spread\frm????.vb:?? 259" String


     


    Code:


                Me.PropertyGrid1.SelectedObject = Nothing
                Dim c As FarPoint.Win.Spread.Model.CellRange = Me.FpSpread1.ActiveSheet.Models.Selection(0)
                Me.PropertyGrid1.SelectedObject = Me.FpSpread1.ActiveSheet.Cells(c.Row, c.Column, c.RowCount, c.ColumnCount)


     


    Select a cell when

  • Replied 8 September 2017, 1:41 pm EST

    It's hard to say what the issue might be here since we can't read the characters in this post.  Could you post a small project showing the problem for us to debug?
  • Replied 8 September 2017, 1:41 pm EST

    zqonline,


    The SelectionChanged event parameters provide first row, first column, number of rows, and number of columns.  The Cells indexer takes first row, first column, last row, last column.  Your code was passing number of rows and number of columns to the Cells indexer when it should have been passing last row and last column.  Change your code from...


        Me.PropertyGrid1.SelectedObject = Me.FpSpread1.ActiveSheet.Cells(c.Row, c.Column, c.RowCount, c.ColumnCount)


    to...


        Me.PropertyGrid1.SelectedObject = Me.FpSpread1.ActiveSheet.Cells(c.Row, c.Column, c.Row + c.RowCount - 1, c.Column + c.ColumnCount - 1)

Need extra support?

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

Learn More

Forum Channels