The following onChange event handler for a RadioButton sets the wrap property of an editor control on the same form to match:

function wrapCheckbox_onChange( )

   form.editor1.wrap := this.value 

In this example, three RadioButtons, whose text properties happen to match the names of the index tags of the current table, use the same onChange event handler. When a different RadioButton is selected, onChange fires twice: once for the RadioButton that was deselected, and once for the button that is selected. The value of the RadioButton is checked to set the index for the RadioButton that was clicked.

function indexRadios_onChange

   if this.value 

      set order to ( this.text ) 

   endif 

 

onChange is also very usefull with a comboBox or columnComboBox to update new items in a dataSource table.

In this example, the onChange event handler for a columnComboBox is used to automatically update a dataSource table:

function editorControl_onChange

   private oQueryRowset

      oQueryRowset = form.Query1.rowset

      if not oQueryRowset.findkey( this.value ) and not empty(this.value)

         // Add new entry

         try

            oQueryRowset.beginAppend()

            oQueryRowset.fields["fld"].value := this.value

            oQueryRowset.save()

            this.datasource = this.datasource  // reload dropdown

            catch (dbexception e)

         endtry

      endif

return