回复 2楼iceman的帖子
Dim im1 = vssDetail.GetInputMap(InputMapMode.WhenFocused)
Dim am = vssDetail.GetActionMap()
im1.Put(New Keystroke(Keys.Enter, Keys.None), "NewControlEnterAction")
Dim newAction As New NewControlEnterAction()
newAction.VssSpread = vssDetail
newAction.Flg = Not bPiIsReadOnly
am.Put("NewControlEnterAction", newAction)
Dim im2 = vssDetail.GetInputMap(InputMapMode.WhenAncestorOfFocused)
im2.Put(New Keystroke(Keys.Enter, Keys.None), "NewControlEnterAction")
Public Class NewControlEnterAction
Inherits FarPoint.Win.Spread.Action
Private _vssDetail As FarPoint.Win.Spread.FpSpread
Private _rowIndex As Integer
Private _colIndex As Integer
Private _bFlg As Boolean = False
Public Property VssSpread() As FarPoint.Win.Spread.FpSpread
Get
VssSpread = _vssDetail
End Get
Set(ByVal value As FarPoint.Win.Spread.FpSpread)
_vssDetail = value
End Set
End Property
Public WriteOnly Property Flg() As Boolean
Set(ByVal Value As Boolean)
_bFlg = Value
End Set
End Property
Public Overrides Sub PerformAction(ByVal sender As Object)
Dim lCol As Integer
Dim lRow As Integer
With _vssDetail.ActiveSheet
lCol = _vssDetail.ActiveSheet.ActiveColumnIndex
lRow = _vssDetail.ActiveSheet.ActiveRowIndex
Do While (lRow <= .RowCount - 1)
If IsOddLine(lRow) Then
lRow = lRow + 1
Else
lRow = lRow - 1
lCol = lCol + 1
End If
If lCol > .ColumnCount - 1 Then
lRow = lRow + 2
lCol = 1
End If
If lRow > .RowCount - 1 Then
Exit Do
End If
If Not _bFlg Then
If .Cells(lRow, lCol).Locked = False And .Columns(lCol).Visible = True Then
If (lRow = 0 AndAlso lCol = 1) OrElse (lRow <> 0 AndAlso lCol = 2) OrElse _
lCol = 3 OrElse lCol = 8 Then
.SetActiveCell(lRow, lCol)
_vssDetail.EditMode = True
Else
.SetActiveCell(lRow, lCol)
_vssDetail.EditMode = False
End If
Exit Do
End If
Else
If lCol = 6 AndAlso lRow Mod 2 = 0 Then
.SetActiveCell(lRow, lCol)
_vssDetail.EditMode = True
Exit Do
Else
If .Cells(lRow, lCol).Locked = False And .Columns(lCol).Visible = True Then
If (lRow = 0 AndAlso lCol = 1) OrElse (lRow <> 0 AndAlso lCol = 2) OrElse _
(lRow Mod 2 = 0 AndAlso lRow < 2 AndAlso lCol = 3) OrElse (lRow Mod 2 = 0 AndAlso lCol = 5) _
OrElse (lRow Mod 2 = 0 AndAlso lCol = 7) OrElse lCol = 8 Then
.SetActiveCell(lRow, lCol)
_vssDetail.ShowColumn(0, lCol, CType(FarPoint.Win.Spread.VerticalPosition.Bottom, HorizontalPosition))
_vssDetail.EditMode = True
ElseIf lRow Mod 2 <> 0 AndAlso lRow >= 2 AndAlso lCol = 3 Then
.SetActiveCell(lRow, lCol)
_vssDetail.ShowColumn(0, lCol, CType(FarPoint.Win.Spread.VerticalPosition.Bottom, HorizontalPosition))
_vssDetail.EditMode = True
Else
.SetActiveCell(lRow, lCol)
_vssDetail.ShowColumn(0, lCol, CType(FarPoint.Win.Spread.VerticalPosition.Bottom, HorizontalPosition))
_vssDetail.EditMode = False
End If
Exit Do
End If
End If
End If
Loop
End With
End Sub
Private Function IsOddLine(ByVal liRow As Integer) As Boolean
If (liRow Mod 2 = 0) Then
IsOddLine = True
Else
IsOddLine = False
End If
End Function
End Class
现在第五列是Combobox列,enter按下后调到第五列就不往下跳了。 |