Posted 9 October 2023, 11:23 pm EST
Hi, I have problem when migrate from ComponentOne VSFlexGrid 8.0 to ComponentOne C1FlexGrid.
In VSFlexGrid 8.0 have property flexSortNumericAscending to sort column like a number even if I set DataType of this column to String in form load
But in C1FlexGrid does not have this property. So I tried it in two ways:
1: In BeforeSort event I change data type of this Int32: C1FlexGrid1.Cols(e.Col).DataType = GetType(Int32).
But it not working. It only work when I clear all data in all cell and rewrite it.
2: I create a Custom Sorting and using it in before sort event but it also not working:
Private Sub C1FlexGrid2_BeforeSort(sender As Object, e As SortColEventArgs) Handles C1FlexGrid2.BeforeSort
C1FlexGrid1.Cols(e.Col).DataType = GetType(Int32)
C1FlexGrid1.Sort(New FileNameComparer(C1FlexGrid2, e.Order))
End Sub
Public Class FileNameComparer
Implements IComparer
Private c1FlexGrid1 As C1FlexGrid
Private _desc As Boolean
Public Sub New(ByVal flex As C1FlexGrid, ByVal order As SortFlags)
c1FlexGrid1 = flex
_desc = ((order And SortFlags.Descending) <> 0)
End Sub
Public Function Compare(r1 As Object, r2 As Object) As Integer Implements IComparer.Compare
Dim s1 As Integer
Integer.TryParse(c1FlexGrid1((TryCast(r1, Row)).Index, 1), s1)
Dim s2 As Integer
Integer.TryParse(c1FlexGrid1((TryCast(r2, Row)).Index, 1), s2)
Dim icmp As Integer = If(s1 > s2, 1, 0)
Return If((_desc), -icmp, icmp)
End Function
End Class
How can I configure the same side as vsflexgrid8. Can you give me some suggestions? Thanks (Note in my case: In form load event I set all data type of all column in grid to String type)