Set active cell childview

Posted by: patrik on 8 June 2019, 5:58 pm EST

    • Post Options:
    • Link

    Posted 8 June 2019, 5:58 pm EST

    Hi

    I get problem sometime with this code.

    it’s working and I get the correct row and column in textbox.

    but sometime it’s hang and I only get row and col to be -1.

    
     Private Sub FpSpread3_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles FpSpread3.MouseDown
            Try
                If e.Button = MouseButtons.Right Then
    
                    Dim sv As FarPoint.Win.Spread.SpreadView
                    Dim cr As FarPoint.Win.Spread.Model.CellRange
    
                    sv = GetSpreadView(FpSpread3.GetRootWorkbook.GetActiveWorkbook(), e.X, e.Y)
                    cr = sv.GetCellFromPixel(0, 0, e.X, e.Y)
                    TextBox1.Text = cr.Row : TextBox2.Text = cr.Column
                End If
            Catch ex As Exception
            End Try
        End Sub
    
     Private Function GetSpreadView(ByVal sv As FarPoint.Win.Spread.SpreadView, ByVal x As Integer, ByVal y As Integer) As FarPoint.Win.Spread.SpreadView
            Try
                Dim r As Rectangle = sv.Bounds
                Dim c As FarPoint.Win.Spread.SpreadView
                Dim ret As FarPoint.Win.Spread.SpreadView
                If Not r.Contains(x, y) Then
                    Return Nothing
                End If
                Dim al As ArrayList = sv.GetChildWorkbooks()
                For Each c In al
                    ret = GetSpreadView(c, x, y)
                    If Not ret Is Nothing Then Return ret
                Next
                Return sv
            Catch Ex As Exception
                Throw Ex
            End Try
        End Function
    
    
    
  • Posted 8 June 2019, 6:10 pm EST

    I change one row and have feeling it’s solve the problem.

    Can this have solve the problem?

    
    Dim al As ArrayList = sv.GetChildWorkbooks
    
    

    to

    
    Dim al As ArrayList = sv.GetRootWorkbook.GetChildWorkbooks
    
    
  • Posted 9 June 2019, 9:17 pm EST

    Hello,

    Actually, “GetRootWorkbook” gets the top view of the spread view. So, in my understanding, it will solve your problem.

    You can also refer the following documentation link:

    https://help.grapecity.com/spread/SpreadNet12/WF/webframe.html#FarPoint.Win.Spread~FarPoint.Win.Spread.SpreadView~GetChildWorkbooks.html

    Thanks.

Need extra support?

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

Learn More

Forum Channels