📚 SAP Business One SDK Help

Sort Method
See Also  Example
sortType
Indicates the sort order.

Description

Sorts the grid or matrix based on this column.

Syntax

Visual Basic
Public Sub Sort( _
   ByVal sortType As BoGridSortType _
) 

Parameters

sortType
ValueDescription
gst_DescendingDescending sort order
gst_AscendingAscending sort order
Indicates the sort order.

Return Type

An error occurs if the Sortable property is false.

An error occurs if the grid is in the expanded state.

Example

Sorting a matrix (Visual Basic)Copy Code
' Get Matrix object
oMatrix = oFirstForm.Items.Item("Matrix").Specific

' Get Column object
oColumn = oMatrix.Columns.Item("CardCode")

' Sort by columnh
oColumn.TitleObject.Sort(SAPbouiCOM.BoGridSortType.gst_Ascending)
Sorting a grid (Visual Basic)Copy Code
oGrid = oFirstForm.Items.Item("MyGrid").Specific
Try
    ' Sort grid
    oGrid.Columns.Item(0).TitleObject.Sort(SAPbouiCOM.BoGridSortType.gst_Ascending)

    Catch ex As Exception
        If oGrid.Columns.Item(0).TitleObject.Sortable = True Then
            ' A grid can't be sorted when collapsed
            SBO_Application.MessageBox("Cannot sort when grid is collapsed")
        Else
            SBO_Application.MessageBox("Cannot sort toward unsortable column")
        End If
End Try

See Also