AllenJ
2017-05-15T20:54:51Z
I was trying to toggle the sort order of the columns, but it complains about the sortorder if-then portion.
How do I get it to toggle ascending/descending?
I trying using the
Dim ord statement to return the ascending/descending values but it keeps complaining, so I then just used the 1 & 2 integers for sort order but it didn't like that either.


    Private Sub IGrid1_ColHdrClick(sender As Object, e As iGColHdrClickEventArgs) Handles IGrid1.ColHdrClick

        With IGrid1
            Dim idx As Integer = .CurColHdr.ColIndex
            If idx < 3 Then
                Dim ord As iGSortOrder
                .SortObject.Clear()
                .SortObject.Add(idx)
                'Debug.Print(.SortObject(idx).SortOrder)
                'If .SortObject(idx).SortOrder = 1 Then
                '    .SortObject(idx).SortOrder = 2
                'Else 
                '    .SortObject(idx).SortOrder = 1
                'End If
                .Sort()
            End If

        End With
    End Sub
Igor/10Tec
2017-05-16T15:43:40Z
The type of the SortOrder property you try to change is iGSortOder, so you need to assign iGSortOrder.Ascending and iGSortOrder.Descending instead of the values 1 and 2. If this does work, can you send us a project that demonstrates this problem?

And why do you need to switch sort order this way by writing your code? It seems, iGrid does what you need by default without additional coding.

Note also that you need to prevent iGrid from doing this default action too if you go this way.
AllenJ
2017-05-16T16:06:53Z
I couldn't seem to get it to sort without going this way.
What properties do I need to set to get it to work?
Thanks.
Igor/10Tec
2017-05-17T07:03:27Z
You do not need to set any properties to allow sorting by column header clicks. This should work "out-of-the-box", i.e. when you drop the control from the VS Toolbox on the form.

Send us, please, a sample that demonstrates your issue.
AllenJ
2017-05-22T19:29:13Z
  Sorting Grid.zip (431kb) downloaded 80 time(s).

Here you go.
Igor/10Tec
2017-05-23T14:15:21Z
Thank you - the project helped to understand why your columns are not sorted by column header clicks. The reason is that you set the SortOrder property for your columns to 'None'. The help topic dedicated to the iGCol.SortOrder property contains the following sentences:

引用:

Note that this property does not reflect the current sort order, it indicates the order of the sort which will be performed when the column's header is clicked if the column was not sorted before.



and

引用:

If None is specified, the column cannot be sorted and grouped through visual interface.



To solve your problem, reset the SortOrder property to its default value 'Ascending' for the required columns.


AllenJ
2017-05-23T16:54:12Z