以下是VB代码:
Public Class Form1
Dim flag As Boolean = True
Public Sub New()
InitializeComponent()
End Sub
Private Sub FpSpread1_GotFocus(sender As Object, e As EventArgs) Handles FpSpread1.GotFocus
flag = True
AddHandler FpSpread1.MouseMove, AddressOf FpSpread1_MouseMove
End Sub
Private Sub FpSpread1_LostFocus(sender As Object, e As EventArgs) Handles FpSpread1.LostFocus
RemoveHandler FpSpread1.MouseMove, AddressOf FpSpread1_MouseMove
End Sub
Private Sub FpSpread1_MouseMove(sender As Object, e As MouseEventArgs)
Dim infor As HitTestInformation = Me.FpSpread1.HitTest(e.X, e.Y)
If infor.Type = HitTestType.Viewport Then
If infor.ViewportInfo.Column = 3 AndAlso infor.ViewportInfo.Row = 3 AndAlso flag Then
MessageBox.Show("Cell " & infor.ViewportInfo.Column.ToString() & ":" & infor.ViewportInfo.Row.ToString())
End If
End If
End Sub
End Class |