KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Creating a combo box alphabetically sorted
PRODUCT: 4D | VERSION: | PLATFORM: Mac & Win
Published On: February 6, 2002

The code described below sorts the contents of the combo box to which it is attached. When a user enters a value, two cases are possible:


The value already exists in the combo box.

- In this case, the element that contains the value entered is made the current element of the combo box.


The value does not exist in the combo box.

- The value is created in the combo box array and the array is sorted.


Case of


 : (Form event=On Data Change )


 If (Find in array(ComboBox1;Combobox1{0})<0)


   INSERT ELEMENT(ComboBox1;Size of array(comboBox1)+1)


   ComboBox1{Size of array(ComboBox1)}:=ComboBox1{0}


   SORT ARRAY(ComboBox1)


 Else


   ComboBox1:=Find in array(ComboBox1;Combobox1{0})


 End if



End case