WireLess Studio Widgets Developer's Guide
WSWDG ContentsWStWidget class reference

ReadRowsFromFile

This method reads the rows of a WS_LIST_CTRL widget from a file.

Ole declaration

VARIANT_BOOL ReadRowsFromFileByName(LPCTSTR sObjectName, LPCTSTR sLocalFileName, LPCTSTR sRemoteFileName);

VARIANT_BOOL ReadRowsFromFileById(SHORT usObjectId, LPCTSTR sLocalFileName, LPCTSTR sRemoteFileName);

Parameters
sObjectName
The name of the target widget.
usObjectId
The id of the target widget.
sLocalFileName
The location (full or relative path) of the file in the local file system.
sRemoteFileName
The location (full path) of the file in the mobile unit file system.
Return Value

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

Remarks

To use this method the current load mode must be WS_LIST_CTRL_LOAD_FROM_MEM (See SetLoadMode for more details).

Each row in the data file must be separated by a new line, also each column must be separated by a semicolon (";").

Data file example
a;s;d;f;g
aliquet.diam@eunulla.edu;;Nampa;78306;Niue;
Donec@sodalesat.org;1 87 707 3855-6484;Chicopee;78265;Bahamas
enim.commodo.hendrerit@etipsumcursus.ca;1 80 239 9006-3928;Mankato;08995;Romania		
Example
C#
using WirelessStudioOleWidgets;
WStWidget oWidget = new WStWidget();
RFFile oFile = new RFFile();
short sListCtrlId= 4;
oFactory.CreateWidgetById((short)WSTFactoryConstants.WS_LIST_CTRL, sListCtrlId, "", 0,0, 50, 50, "");
oWidget.AddColumById(sListCtrlId, 40, "Product Id");
oFile.RFTransferFile("../SamplesWidgets\Exe\Resources\data.txt", oFile.GetRemoteTempFolder() + "\data.txt", True);
oWidget.SetLoadModeById(sListCtrlId, (short)WSTWidgetConstants.WS_LIST_CTRL_LOAD_FROM_FILE);
oWidget.ReadRowsFromFileById(sListCtrlId, "../SamplesWidgets\Exe\Resources\data.txt", sRemoteTempFolder + "\data.txt");
Visual Basic 6 (Full Example: ListCtrlDemoModule.bas.txt)
Public wsWidget As New WStWidget
...
Case "loadRowsFromDataBtn"
	'Fulfills the WS_LISTCTRL widget using the data.txt file
	wsWidget.SetLoadModeByName "myListCtrl", WS_LIST_CTRL_LOAD_FROM_FILE
	wsWidget.ReadRowsFromFileByName "myListCtrl", "../SamplesWidgets\Exe\Resources\data.txt", _
	sRemoteTempFolder + "\data.txt"
...
See also

SetRowText | DeleteRow | SetRowIcon | AddRow | ClearRows | AddColumn | ClearColumns | GetSelectedItem | SetLoadMode

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