Problem with Updating a LISTBOX

Problem with Updating a LISTBOX

Postby Ollie » 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.


Code: Select all  Expand view
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)
Ollie
 
Posts: 233
Joined: Sat Dec 30, 2006 6:10 am

Postby Antonio Linares » Wed Jul 04, 2007 11:08 am

Code: Select all  Expand view
   @  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
User avatar
Antonio Linares
Site Admin
 
Posts: 42078
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Ollie » 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)
Ollie
 
Posts: 233
Joined: Sat Dec 30, 2006 6:10 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 47 guests