Page 1 of 1

TwBrowse question

Posted: Mon Apr 02, 2007 12:01 pm
by Milan Mehta
Dear All,

I am normally using TwBrowse Listbox with normal syntax of REDEFINE LISTBOX.... But in a typical situation, I want to assign columns to the listbox programmatically. I saw that it is being passed as second parameter as Code block. My data is in an array and I want to pass all the columns as field for the listbox.
e.g. {|| { oReport:ArrData[nItem,1],oReport:ArrData[nItem,2] } }

How can I assing columns in the code block in a loop ?

I hope somebody understand my problem and give some suggestion. I have difficulty in explaining my problem.

With best regards,

Milan.

Posted: Mon Apr 02, 2007 12:24 pm
by Antonio Linares
Milan,

Just call a function from the codeblock, and in the function do whatever you may need:

{ || MyFunction() }

...

function MyFunction()

local aValues

// Build aValues the way you need it

return aValues

Posted: Mon Apr 02, 2007 2:49 pm
by Milan Mehta
Dear Antonio,

My following code do not give desired result :

nItem := 1
REDEFINE LISTBOX oBrw FIELDS RetRecord(oReport:ArrData, nItem) ;
COLSIZES 50, 80;
HEADERS 'Code', 'Name';
FONT oFont ;
UPDATE ;
ID LBREPORT OF oDlg
............

FUNCTION RetRecord(aArrData, nItem)
LOCAL i, aRetVal := {}
FOR i = 1 TO len(aArrData[nItem])
AADD (aArrData, aArrData[nItem, i])
NEXT

RETURN aRetVal

What am I doing wrong ?

TIA
Milan.

Posted: Mon Apr 02, 2007 4:34 pm
by Antonio Linares
Try this:

REDEFINE LISTBOX oBrw FIELDS "", "" ;
...

oBrw:bLine = { || RetRecord(oReport:ArrData, nItem) }