问:
我想要实现的是:如果在单元格中输入的是数字,光标离开时,弹出MSG,并把光标返回原单元格。
问题是:我做了以下处理以后,光标会先返回原单元格,然后又移动到下一个单元格。有一个闪动的过程。
Public Class Form1
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
If IsNumeric(FpSpread1.ActiveSheet.Cells(intR, 0).Value) Then
MsgBox("IsNumeric,Focus Back!")
Me.FpSpread1.ActiveSheet.SetActiveCell(intR, 0)
End If
End Sub
End Class
版本信息:
SPREAD for .NET 3.0J Windows Forms Edition リリースノート
Version 3.0.2010.2005
问题是:我做了以下处理以后,光标会先返回原单元格,然后又移动到下一个单元格。有一个闪动的过程。
Public Class Form1
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
If IsNumeric(FpSpread1.ActiveSheet.Cells(intR, 0).Value) Then
MsgBox("IsNumeric,Focus Back!")
Me.FpSpread1.ActiveSheet.SetActiveCell(intR, 0)
End If
End Sub
End Class
版本信息:
SPREAD for .NET 3.0J Windows Forms Edition リリースノート
Version 3.0.2010.2005
答:
不是办法的办法
本身没有什么好的办法。试一下下面这个吧,这个可以先解决你的可题。
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
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
Spread for Windows Forms产品介绍和下载地址:http://www.componentcn.com/?thread-6547-1.html