Thanks for the reply.
I’ve managed to solve the issue with implementing some code in the FocusedCellChanged event.
Below is my solution. I’ve also attached a video of how to reproduce in Excel.
Public prevSelection As Aspose.Cells.GridDesktop.CellLocation
Public bBusy As Boolean = False
Private Sub GridDesktop1_FocusedCellChanged(sender As Object, e As Aspose.Cells.GridDesktop.CellEventArgs) Handles GridDesktop1.FocusedCellChanged
If bBusy = True Then Exit Sub
Dim cell As Aspose.Cells.GridDesktop.GridCell = GridDesktop1.GetActiveWorksheet.GetFocusedCell 'e.Cell
Dim loc As Aspose.Cells.GridDesktop.CellLocation = cell.Location
Dim style As Aspose.Cells.GridDesktop.Style = cell.GetStyle()
Dim sheet As Aspose.Cells.GridDesktop.Worksheet = GridDesktop1.GetActiveWorksheet()
If prevSelection Is Nothing Then prevSelection = cell.Location
If style.CellLocked = True Then
Dim directionRow As Integer = 0
Dim directionCol As Integer = 0
If prevSelection.Row < cell.Location.Row Then
directionRow = 1
ElseIf prevSelection.Row > cell.Location.Row Then
directionRow = -1
End If
If prevSelection.Column < cell.Location.Column Then
directionCol = +1
ElseIf prevSelection.Column > cell.Location.Column Then
directionCol = -1
End If
If directionCol <> 0 Then
Dim iRow As Long = cell.Location.Row
Dim iStartCol As Long
Dim iEndCol As Long
Dim iStep As Long
If directionCol < 0 Then
iStartCol = cell.Location.Column
iEndCol = 0
iStep = -1
Else
iStartCol = cell.Location.Column
iEndCol = GridDesktop1.GetActiveWorksheet.ColumnsCount
iStep = 1
End If
Dim bFound As Boolean = False
bBusy = True
For col As Integer = iStartCol To iEndCol Step iStep
sheet.SetFocusedCell(New Aspose.Cells.GridDesktop.CellLocation(iRow, col))
If GridDesktop1.GetActiveWorksheet.GetFocusedCell.Style.CellLocked = False Then
prevSelection = New Aspose.Cells.GridDesktop.CellLocation(iRow, col)
bFound = True
Exit For
End If
Next
If bFound = False Then
sheet.SetFocusedCell(New Aspose.Cells.GridDesktop.CellLocation(prevSelection.Row, prevSelection.Column))
prevSelection = New Aspose.Cells.GridDesktop.CellLocation(prevSelection.Row, prevSelection.Column)
End If
bBusy = False
End If
If directionRow <> 0 Then
Dim iCol As Long = cell.Location.Column
Dim iStartRow As Long
Dim iEndRow As Long
Dim iStep As Long
If directionRow < 0 Then
iStartRow = cell.Location.Row
iEndRow = 0
iStep = -1
Else
iStartRow = cell.Location.Row
iEndRow = GridDesktop1.GetActiveWorksheet.RowsCount
iStep = 1
End If
Dim bFound As Boolean = False
bBusy = True
For row As Integer = iStartRow To iEndRow Step iStep
sheet.SetFocusedCell(New Aspose.Cells.GridDesktop.CellLocation(row, iCol))
If GridDesktop1.GetActiveWorksheet.GetFocusedCell.Style.CellLocked = False Then
prevSelection = New Aspose.Cells.GridDesktop.CellLocation(row, iCol)
bFound = True
Exit For
End If
Next
If bFound = False Then
sheet.SetFocusedCell(New Aspose.Cells.GridDesktop.CellLocation(prevSelection.Row, prevSelection.Column))
prevSelection = New Aspose.Cells.GridDesktop.CellLocation(prevSelection.Row, prevSelection.Column)
End If
bBusy = False
End If
Else
prevSelection = GridDesktop1.GetActiveWorksheet.GetFocusedCell.Location()
End If
End Sub