Page 1 of 1

Enabling/Disabling a control on the fly

Posted: Sat Jun 13, 2009 5:58 am
by sudip
Hi all,

I have 2 input controls, Combobox and Checkbox. I want to make that, when check box is on combo box will be disabled and when check box is off, combo box will be enabled.

Following code doesn't work:-

Code: Select all

      @ 40, 80 COMBOBOX cboExpid ;
      	width 300 ;
      	items aExpnm ;
      	value 0 
		@ 40, 400 checkbox chkAllexp caption "All expense heads" ;
			width 200 value .t. ;
			on change {|| frmTranPrint.cboExpid.value := iif(this.value, 0, frmTranPrint.cboExpid.value), ;
				frmTranPrint.cboExpid.enabled := !this.value} 
  
But following code works:-

Code: Select all

      @ 40, 80 COMBOBOX cboExpid ;
      	width 300 ;
      	items aExpnm ;
      	value 0 
		@ 40, 400 checkbox chkAllexp caption "All expense heads" ;
			width 200 value .t. ;
			on change {|| frmTranPrint.cboExpid.value := iif(this.value, 0, frmTranPrint.cboExpid.value), ;
				frmTranPrint.cboExpid.enabled := !frmTranPrint.chkAllExp.value} 
  
For running demo of this problem please download download/file.php?id=248 and open TranPrint.prg. :)

I don't have any explanation for this. :?
Can you please explain this behavior?

TIA.

With best regards.

Sudip