回复 4楼aladdin的帖子
aladdin 你好,
可以通过 TextCellType 的 txtType_EditingStopped 事件接受回车事件,判断活跃单元格(有可能是通过鼠标点击切换编辑状态)为编辑单元格。如果是,则切换焦点:
- WithEvents txtType As New FarPoint.Win.Spread.CellType.TextCellType
- Dim isCur As Boolean
- Dim activeRow As Int32
- Dim activeCol As Int32
- Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
- Dim rowCount As Int32
- Dim colCount As Int32
- rowCount = Me.FpSpread1.Sheets.Item(0).RowCount
- colCount = Me.FpSpread1.Sheets.Item(0).ColumnCount
- Me.FpSpread1.Sheets.Item(0).Cells(rowCount - 1, colCount - 1).CellType = txtType
- activeRow = 0
- activeCol = 0
- isCur = True
- End Sub
- Private Sub txtType_EditingStopped(sender As Object, e As System.EventArgs) Handles txtType.EditingStopped
- Dim curActiveRow As New Int32
- curActiveRow = Me.FpSpread1.Sheets(0).ActiveRowIndex
- Dim curActiveCol As New Int32
- curActiveCol = Me.FpSpread1.Sheets(0).ActiveColumnIndex
- If ((curActiveCol <> Me.activeCol) OrElse (curActiveRow <> Me.activeRow)) Then
- Me.isCur = False
- Me.activeCol = curActiveCol
- Me.activeRow = curActiveRow
- Else
- Me.isCur = True
- End If
- If Me.isCur Then
- Me.FpSpread2.Focus()
- End If
- End Sub
- Private Sub txtType_EditorValueChanged(sender As Object, e As System.EventArgs) Handles txtType.EditorValueChanged
- activeRow = Me.FpSpread1.Sheets.Item(0).ActiveRowIndex
- activeCol = Me.FpSpread1.Sheets.Item(0).ActiveColumnIndex
- End Sub
复制代码 |