回复 2楼Alice的帖子
大致代码如下:
Public Structure SortInfo
Dim intSortCol As Short 'ソート対象列番号
Dim intSortOrder As Boolean 'ソート条件(昇順/降順)
End Structure
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim intCol As Short
Dim udtSortInfo(0) As SortInfo
udtSortInfo(0) = New SortInfo
'ソート条件の設定
With udtSortInfo(0)
intCol = 1
.intSortCol = intCol
'昇順/降順の設定
If (CheckBox1.Checked = True) Then
'昇順
.intSortOrder = True
Else
'降順
.intSortOrder = False
End If
End With
'スプレッドのソート
Call g_SortSpread(FpSpread1, udtSortInfo, , True)
End Sub
Public Sub g_SortSpread(ByRef spdSpread As FarPoint.Win.Spread.FpSpread, ByRef udtSortInfo() As SortInfo, Optional ByRef lngNoNoCol As Integer = 0, Optional ByVal needSortEmpty As Boolean = False)
Dim intNum As Short 'ソート条件設定用No
Dim spdRow As Integer
Dim spdSortInfo() As FarPoint.Win.Spread.SortInfo = Nothing
With spdSpread
.SuspendLayout()
'ソート範囲の指定
spdRow = 0
'ソート条件の設定
intNum = 0
For intCounter = LBound(udtSortInfo) To UBound(udtSortInfo)
ReDim Preserve spdSortInfo(intNum)
If needSortEmpty Then
spdSortInfo(intNum) = New FarPoint.Win.Spread.SortInfo(udtSortInfo(intCounter).intSortCol, udtSortInfo(intCounter).intSortOrder, System.Collections.Comparer.Default)
Else
spdSortInfo(intNum) = New FarPoint.Win.Spread.SortInfo(udtSortInfo(intCounter).intSortCol, udtSortInfo(intCounter).intSortOrder)
End If
intNum = intNum + 1
Next intCounter
'ソート対象の設定(列でソート)
.Sheets(0).SortRows(spdRow, .Sheets(0).RowCount, spdSortInfo)
.ResumeLayout()
End With
End Sub
然后,spread的celltype都是text型的。数据的话如1楼所示。 |