WireLess Studio Widgets Developer's Guide
WSWDG ContentsWStWidget class reference

SetSelectedItem

Sets the current selected item on a WS_LIST_CTRL (an item is a row) or a WS_MENU (an item is an option) widget.

Ole declaration

VARIANT_BOOL SetSelectedItemById(SHORT usObjectId, SHORT usItemIndex);

VARIANT_BOOL SetSelectedItemByName(LPCTSTR sObjectName, SHORT usItemIndex);

Parameters
sObjectName
The name of the target widget.
usObjectId
The id of the target widget.
usItemIndex
The index of the item that will be selected.
Return Value

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

Remarks

This method is not supported by the WS_MENU widget if it's current menu type is WS_BUTTON_MENU_TYPE.

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, "33413");
oWidget.SetSelectedItemById(sListCtrlId, 0);
Visual Basic 6 (Full Example: MenuDemoModule.bas.txt)
Public wsWidget As New WStWidget
...
Case "selectedOptionField"
	iSelectedOption = wsForm.GetLastEventStrValue()
	wsWidget.SetSelectedItemByName "listBoxMenu", iSelectedOption
	wsWidget.SetSelectedItemByName "buttonMenu", iSelectedOption
	wsWidget.SetSelectedItemByName "comboBoxMenu", iSelectedOption
...
See also

DeleteRow | SetRowIcon | AddRow | ClearRows | AddColumn | ClearColumns | GetSelectedItem | ReadRowsFromFile | GetItemCount | SetLoadMode

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