我没有用Spread自带的排序方法而是自己手动写了代码进行排序的,但是这样处理之后原先Spread内设置的每一行的格式,如背景色字体色等不会根据排序后的顺序重新设定格式,而是固定的继续保持在我排序前的行位置,求教有什么办法可以修改
排序代码如下
Public Shared Sub SpdSort(ByRef vssioTarget As FarPoint.Win.Spread.SheetView, ByVal liCol As Integer, _
ByVal liStartRow As Integer, ByVal liEndRow As Integer, ByVal liStartCol As Integer, _
ByVal liEndCol As Integer, ByVal niSortKeyOrder As Integer)
If liCol = -1 OrElse niSortKeyOrder = SortIndicator.None Then
Return
End If
Dim mpcLastPointer As System.Windows.Forms.Cursor
mpcLastPointer = System.Windows.Forms.Cursor.Current
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor ' Screen
Dim sortOrder As Boolean = True
If niSortKeyOrder = SortIndicator.Descending Then
sortOrder = False
End If
Dim sort(1) As FarPoint.Win.Spread.SortInfo
sort(0) = New FarPoint.Win.Spread.SortInfo(liCol, sortOrder)
vssioTarget.SortRange(liStartRow, liStartCol, liEndRow - liStartRow + 1, liEndCol - liStartCol + 1, True, sort)
System.Windows.Forms.Cursor.Current = mpcLastPointer
End Sub |
|