WireLess Studio Widgets Developer's Guide
WSWDG ContentsWStWidget class reference

SetSortMode

Allows the user to sort the items of a WS_LIST_CTRL widget in ascending or descending order when he clicks a column of the widget's header.

Ole declaration

VARIANT_BOOL SetSortModeByName(LPCTSTR sObjectName, SHORT usMode);

VARIANT_BOOL SetSortModeById(SHORT usObjectId, SHORT usMode);

Parameters
sObjectName
The name of the target widget.
usObjectId
The id of the target widget.
usMode
The new sort mode. See the remarks for its available values.
Return Value

On success, SetSortMode returns TRUE, FALSE otherwise. To get extended information, call WStError::GetLastErrorCode.

Remarks

Modes to be set can be combined by using the bitwise OR ( | ) operator.

The available sort modes are:

The display modes can be found on the WSTWidgetConstants enumeration.

Example
C#
using WirelessStudioOleWidgets;
WStWidget oWidget = new WStWidget();
short sListCtrlId= 4;
oFactory.CreateWidgetById((short)WSTFactoryConstants.WS_LIST_CTRL, sListCtrlId, "", 0,0, 50, 50, "");
oWidget.AddColumById(sListCtrlId, 40, "Product Id");
oWidget.AddRowById(sListCtrlId, 0);
oWidget.SetRowTextById(sListCtrlId, 0, 0, "1");
oWidget.AddRowById(sListCtrlId, 0);
oWidget.SetRowTextById(sListCtrlId, 1, 0, "2");
oWidget.AddRowById(sListCtrlId, 0);
oWidget.SetRowTextById(sListCtrlId, 2, 0, "3");
oWidget.SetSortModeById(sListCtrlId, (short)(WSTWidgetConstants.WS_LIST_CTRL_SORT_ASCENDING | WSTWidgetConstants.WS_LIST_CTRL_SORT_ASCENDING));
Visual Basic 6 (Full Example: ListCtrlDemoModule.bas.txt)
Public wsWidget As New WStWidget
...
 Case "sortCheckBox"
	If wsWidget.GetStateByName("sortCheckBox") = WS_STATE_CHECKED Then
		wsWidget.SetSortModeByName "myListCtrl", WS_LIST_CTRL_SORT_DESCENDING + _
			WS_LIST_CTRL_SORT_ASCENDING
	Else
		wsWidget.SetSortModeByName "myListCtrl", WS_LIST_CTRL_SORT_DISABLED
	End If
...
See also

SetRowText | DeleteRow | AddRow

WStWiget class reference | WStForm class reference | WStFactory class reference | WStError class reference