FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Problem with Updating a LISTBOX
Posts: 233
Joined: Sat Dec 30, 2006 06:10 AM
Problem with Updating a LISTBOX
Posted: Wed Jul 04, 2007 10:22 AM
Please can someone tell me what I am doing wrong.

I want the 2nd Listbox items to change based on the selection of the first.

I have also tried oLbx2:REFRESH(),oDlg:UPDATE(),sysrefresh() in the ON CHANGE for oLbx1 - the second listbox just won't change.

The code below is a complete selfcontained example.


PROCEDURE LISTBOXTEST()
   LOCAL oDlg
   LOCAL aitems1,aitems2,aitems3, cValue1, cValue2, cValue3

   aItems1:={"1","2"}
   cValue1:=aItems1[2]

   aItems2:={"3","4","5"}
   cValue2:=aItems2[2]

   DEFINE DIALOG oDlg FROM 5,10 TO 24, 55 TITLE "ListBoxTest"

   @  1, 2 LISTBOX oLbx1 VAR cValue1 ITEMS aItems1 SIZE 45, 95 OF oDlg UPDATE ;
   ON CHANGE (IF(cValue1="1",aItems2:={"a","b","c"},aItems2:={"X","Y","Z"}),oDlg:UPDATE())

    @  1, 14 LISTBOX oLbx2 VAR cValue2 ITEMS aItems2 SIZE 45, 95 OF oDlg UPDATE

   @ 7, 7 BUTTON "&OK" OF oDlg SIZE 40, 12 ;
     ACTION oDlg:End() DEFAULT

   @ 7, 17 BUTTON "&Cancel" OF oDlg SIZE 40, 12 ;
     ACTION ( cValue1 := nil, oDlg:End() )

   ACTIVATE DIALOG oDlg CENTERED
   RETURN
Many thanks

Ollie.



Using:

xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6406)

Borland C++ 5.5.1

FWH 9.04 (2009 Apr)
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Problem with Updating a LISTBOX
Posted: Wed Jul 04, 2007 11:08 AM
   @  1, 2 LISTBOX oLbx1 VAR cValue1 ITEMS aItems1 SIZE 45, 95 OF oDlg UPDATE ; 
   ON CHANGE (IF(cValue1="1",aItems2:={"a","b","c"},aItems2:={"X","Y","Z"}),oLbx2:SetItems( aItems2 ), oDlg:UPDATE())
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 233
Joined: Sat Dec 30, 2006 06:10 AM
Problem with Updating a LISTBOX
Posted: Wed Jul 04, 2007 11:56 AM

Thank you. That did it.

Many thanks

Ollie.



Using:

xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6406)

Borland C++ 5.5.1

FWH 9.04 (2009 Apr)

Continue the discussion