Page 1 of 1

Listbox Help

Posted: Tue Jun 27, 2006 6:02 pm
by Jeff Barnes
Hi Everybody,

I'll try to explain this as best I can....

I have a listbox created from resource.
When the listbox is first created there is no database associated with it
(REDEFINE LISTBOX oLbx ID 131 of oDlg UPDATE)

When the user selects a database file drop a drop down list, I need to display 3 fields from this database.

I need to re-define the listbox with the new database.
I have tried doing a:

REDEFINE Listbox oLbx FIELDS RepData->Time, STR(RepData->Sat), STR(RepData->HR) ID 131 ;
FIELDSIZES 60,35,35 ;
HEAD "Time","SPO2","HR";
of oDlg UPDATE

but it gives me a duplicate ID error.

Any ideas to get around this problem?

Thanks in advance,

Jeff

Posted: Tue Jun 27, 2006 9:17 pm
by Gale FORd
Have you tried

oLbx := nil

REDEFINE Listbox oLbx FIELDS RepData->Time, STR(RepData->Sat), STR(RepData->HR) ID 131 ;
FIELDSIZES 60,35,35 ;
HEAD "Time","SPO2","HR";
of oDlg UPDATE

Posted: Wed Jun 28, 2006 8:02 am
by Antonio Linares
Jeff,

Try to use three dummy fields since the beginning:

REDEFINE LISTBOX oLbx FIELDS "", "", "" ID 131 of oDlg UPDATE

and later on set its DATA bLine:

oLbx:bLine = { || { RepData->Time, STR(RepData->Sat), STR(RepData->HR) } }

(Please notice that it is a codeblock that returns an array)

and oLbx:Refresh()

Posted: Thu Sep 14, 2006 2:47 pm
by Jeff Barnes
I am now back to this listbox issue....

I am using the following code to reload the listbox with new data:

oLbx:bLine := { || { RepData->Time, STR(RepData->Sat), STR(RepData->HR) } }

All I get in the listbox is the first entry in the database repeated 5 times.

Any Ideas?


Thanks,
Jeff

Posted: Thu Sep 14, 2006 4:47 pm
by Enrico Maria Giordano
You have to assign oLbx:bLogicLen too.

EMG

Posted: Thu Sep 14, 2006 5:31 pm
by Jeff Barnes
Enrico,

I have added:

oLbx:bLogicLen = { || RecCount() }

Still get the first record repeated 5 times. Sample of code below.



Function LoadSat() //called from function that displays the listbox
use "\MyFile.dbf" SHARED ALIAS "RepData" NEW
Select RepData
Go Top
oLbx:bLine := { || { RepData->Time, STR(RepData->Sat), STR(RepData->HR) } }
oLbx:bLogicLen()
oLbx:ReFresh()
Return Nil


Any Ideas?

Jeff

Posted: Thu Sep 14, 2006 5:49 pm
by James Bott
Jeff,

You have to use the ALIAS clause in the listbox definition.

James

Posted: Thu Sep 14, 2006 6:21 pm
by Jeff Barnes
Now I'm lost ... I don't see any ALIAS clause in the help file. This is what I have in my help file....


REDEFINE LISTBOX [ <oLbx> VAR ] <cnVar> ;

[ ITEMS | PROMPTS <aItems> ] ;
[ FILES | FILESPEC <cFileSpec> ] ;
[ ID <nId> ] ;
[ ON CHANGE <uChange> ] ;
[ ON [ LEFT ] DBLCLICK <uLDblClick> ] ;
[ OF | WINDOW | DIALOG <oWnd> ] ;
[ HELPID | HELP ID <nHelpId> ] ;
[ BITMAPS [ SIZE <nSize> ] ] ;
[ VALID <uValid> ] ;
[ COLOR | COLORS <nClrFore> [,<nClrBack>] ] ;
[ MESSAGE <cMsg> ] ;
[ UPDATE ] ;
[ WHEN <uWhen> ]

[ BITMAPS <aBitmaps> ] ;
[ ON DRAWITEM <uBmpSelect> ]

Posted: Thu Sep 14, 2006 7:16 pm
by Enrico Maria Giordano
Please look in Fivewin.ch instead. It is the best documentation. :-)

EMG

Posted: Thu Sep 14, 2006 7:57 pm
by Jeff Barnes
Thanks guys.

It works perfectly now.


Jeff