Combobox with WHEN command

Combobox with WHEN command

Postby Silvio.Falconi » Mon Feb 18, 2019 8:40 pm

Image



I wish when the user select on 4th item of the first combobox is activate the second combobox

the test code
Code: Select all  Expand view
#include "fivewin.ch"

Function Test()
Local oDlg
Local aGet[10]
Local nTariffeshow:= 1
Local nTipoShow:= 1
Local aShowTariffe:={"Tutte","Elementi","Pacchetti","Servizi"}
local oCbx2,ocbx3
local aServizi:={{"SERVIZIO1",""},;
                 { "SERVIZIO2",""},;
                 { "SERVIZIO3",""},;
                 { "SERVIZIO4",""} }


DEFINE DIALOG oDlgtariffe size 400,400

  @ 10,25 COMBOBOX oCbx2 VAR  nTariffeshow ITEMS aShowTariffe   ;
   SIZE 100,400 PIXEL OF oDlgTariffe  ;
  ON CHANGE ( msginfo(str(nTariffeshow),oCbx2:nat),oCbx3:refresh())

   @ 60,25 COMBOBOX oCbx3 VAR nTiposhow ITEMS ArrTranspose( aServizi )[ 1]  ;
   SIZE 120,400 PIXEL OF oDlgTariffe UPDATE  WHEN oCbx2:nat=4



activate dialog  oDlgTariffe center
return nil
 


when I select "servizi" on first combobox , the second combobox is changed but not it enable

where is the error ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7056
Joined: Thu Oct 18, 2012 7:17 pm

Re: Combobox with WHEN command

Postby karinha » Tue Feb 19, 2019 5:11 pm

Look at this,

Code: Select all  Expand view

#include "fivewin.ch"

STATIC lShowCmb := .T.

FUNCTION Test()

   LOCAL oDlg, oDlgtariffe
   LOCAL aGet[10]
   LOCAL nTariffeshow := 1
   LOCAL nTipoShow := 1
   LOCAL aShowTariffe := { "Tutte", "Elementi", "Pacchetti", "Servizi" }
   LOCAL oCbx2, ocbx3
   LOCAL aServizi := { { "SERVIZIO1", "" }, ;
                       { "SERVIZIO2", "" }, ;
                       { "SERVIZIO3", "" }, ;
                       { "SERVIZIO4", "" } }

   DEFINE DIALOG oDlgtariffe size 400, 400 ;
          TITLE "CHANGE MY COMBO"

   oDlgtariffe:lHelpIcon := .F.

   @ 10, 25 COMBOBOX oCbx2 VAR  nTariffeshow ITEMS aShowTariffe   ;
      SIZE 100, 400 PIXEL OF oDlgTariffe  ;
      ON CHANGE ( CAMBIA_COMBO( oCbx2, oCbx3 ) )

   @ 60, 25 COMBOBOX oCbx3 VAR nTiposhow ITEMS ArrTranspose( aServizi )[ 1]  ;
      SIZE 120, 400 PIXEL OF oDlgTariffe UPDATE WHEN( lShowCmb )

   ACTIVATE DIALOG  oDlgTariffe CENTER

RETURN nil
// I LOVE FIVEWIN THE BEST. SIMPLE TO USE.
// change combobox
FUNCTION CAMBIA_COMBO( oCbx2, oCbx3 )

  IF( oCbx2:nAt ) == 4  // Absolute = Disable the combo

     lShowCmb := .F.

     oCbx3:Disable()
     oCbx3:Refresh()

  ELSE // Enable the combo - I'm terrible. jajajajajajajaja.

     lShowCmb := .T.

     oCbx3:Enable()
     oCbx3:Refresh()

  ENDIF

RETURN NIL
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7812
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Combobox with WHEN command

Postby nageswaragunupudi » Tue Feb 19, 2019 6:05 pm

Mr. Silvio

Just add oDlg:AEvalWhen() in the ON CHANGE clause of the first COMBOBOX.

This is the revised program:
Code: Select all  Expand view
#include "fivewin.ch"

Function Test()
   local oDlgTariffe
   local aGet[10]
   local nTariffeshow:= 1
   local nTipoShow:= 1
   local aShowTariffe:={"Tutte","Elementi","Pacchetti","Servizi"}
   local oCbx2,ocbx3
   local aServizi:={{"SERVIZIO1",""},;
                    { "SERVIZIO2",""},;
                    { "SERVIZIO3",""},;
                    { "SERVIZIO4",""} }

   DEFINE DIALOG oDlgtariffe SIZE 400,400

   @ 10,25 COMBOBOX oCbx2 VAR nTariffeshow ITEMS aShowTariffe   ;
      SIZE 100,400 PIXEL OF oDlgTariffe  ;
      ON CHANGE ( MsgInfo( Str( nTariffeshow ), oCbx2:nat ), ;
                  oDlgTariffe:AEvalWhen() )

   @ 60,25 COMBOBOX oCbx3 VAR nTiposhow ITEMS ArrTranspose( aServizi )[ 1]  ;
      SIZE 120,400 PIXEL OF oDlgTariffe UPDATE WHEN oCbx2:nat = 4

   ACTIVATE DIALOG oDlgTariffe CENTER

return nil
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10631
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Combobox with WHEN command

Postby Silvio.Falconi » Tue Feb 19, 2019 8:28 pm

Thanks Rao
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7056
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: nageswaragunupudi, Willi Quintana and 66 guests