Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load If IsPostBack Then Return Dim g As New FarPoint.Web.Spread.ComboBoxCellType g.Items = New String() {“S”, “J”, “R1”, “R2”, “D”} g.Values = New String() {“34”, “32”, “5”, “4”, “0”} FpSpread1.Sheets(0).Columns(1).CellType = g FpSpread1.Sheets(0).AllowSort = True End Sub Private Sub FpSpread1_SortColumnCommand(ByVal sender As Object, ByVal e As FarPoint.Web.Spread.SpreadCommandEventArgs) Handles FpSpread1.SortColumnCommand Dim c As FarPoint.Web.Spread.ComboBoxCellType Dim asc As Boolean = Session(“SaveAsc”) If e.CommandArgument = 1 Then asc = Not asc e.Handled = True c = CType(FpSpread1.Sheets(0).GetCellType(-1, e.CommandArgument), FarPoint.Web.Spread.ComboBoxCellType) FpSpread1.Sheets(0).SortRows(1, asc, True, New ComboComparer(c)) Session(“SaveAsc”) = asc End If End Sub
Public Class ComboComparer
Implements System.Collections.IComparer Dim combo As FarPoint.Web.Spread.ComboBoxCellType Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer Implements System.Collections.IComparer.Compare Dim cVal1 As String = combo.Items(Array.IndexOf(combo.Values, x.ToString)) Dim cVal2 As String = combo.Items(Array.IndexOf(combo.Values, y.ToString)) Return System.Collections.Comparer.Default.Compare(cVal1, cVal2) End Function Public Sub New(ByVal c As FarPoint.Web.Spread.ComboBoxCellType) combo = c End Sub End Class
|