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