本身没有什么好的办法。试一下下面这个吧,这个可以先解决你的可题。
Public Class Form1
Dim intR As Integer = -1
Dim intC As Integer = -1
Public Sub SetEnterKey(ByVal FpSpread As FarPoint.Win.Spread.FpSpread)
Dim im As New FarPoint.Win.Spread.InputMap()
' 非編集セルでの[Enter]キーを「次列へ移動」とします
im = FpSpread.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenFocused)
im.Put(New FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.None), FarPoint.Win.Spread.SpreadActions.MoveToNextColumnWrap)
im.Put(New FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.Shift), FarPoint.Win.Spread.SpreadActions.MoveToPreviousColumnWrap)
' 編集中セルでの[Enter]キーを「次列へ移動」とします
im = FpSpread.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenAncestorOfFocused)
im.Put(New FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.None), FarPoint.Win.Spread.SpreadActions.MoveToNextColumnWrap)
im.Put(New FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.Shift), FarPoint.Win.Spread.SpreadActions.MoveToPreviousColumnWrap)
'' SPREADにフォーカスを移動させます
'FpSpread.Focus()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
SetEnterKey(Me.FpSpread1)
End Sub
Private Sub FpSpread1_Change(ByVal sender As System.Object, ByVal e As FarPoint.Win.Spread.ChangeEventArgs) Handles FpSpread1.Change
'Dim intR As Integer = Me.FpSpread1.ActiveSheet.ActiveRowIndex
intR = Me.FpSpread1.ActiveSheet.ActiveRowIndex
intC = Me.FpSpread1.ActiveSheet.ActiveColumnIndex
If IsNumeric(FpSpread1.ActiveSheet.Cells(intR, intC).Value) Then
MsgBox("IsNumeric,Focus Back!")
'Me.FpSpread1.ActiveSheet.SetActiveCell(intR, 0)
Else
intR = -1
intC = -1
End If
End Sub
Private Sub FpSpread1_EnterCell(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.EnterCellEventArgs) Handles FpSpread1.EnterCell
If intR <> -1 Then Me.FpSpread1.ActiveSheet.SetActiveCell(intR, intC)
End Sub
End Class |