Form With a Combobox Crashes in Visual dBASE 5.6/5.7

The Problem: There is a minor bug in the way Comboboxes work in Visual dBASE 5.6 and 5.7 (which did not occur in 5.5) -- if you use the designer to create an array for your dataSource, the form will crash when run.

The Solution: It takes a small amount of work. First, remove the datasource in the form designer if you can. If not, you can bring the form into the source editor and remove the DATASOURCE statement from the constructor code. It would look something like:

   DEFINE COMBOBOX COMBOBOX1 OF THIS;
       PROPERTY;
         DataSource 'ARRAY {"Test","Test2","Test3"}',;
         FontBold .F.,;
         Top 4,;
         Left 12,;
         Style 1,;
         Height 1.2344,;
         Width 17

Remove the datasource property so the code looks like:

   DEFINE COMBOBOX COMBOBOX1 OF THIS;
       PROPERTY;
         FontBold .F.,;
         Top 4,;
         Left 12,;
         Style 1,;
         Height 1.2344,;
         Width 17

Now, in the form's onOpen event (or the combobox's onOpen event), which you can create or modify in the designer, create a "real" array, and set the datasource that way:

function Form_onopen
   form.array1 = new array()
   form.array1.add( "Test" )
   form.array1.add( "Test2" )
   form.array1.add( "Test3" )
   form.combobox1.datasource = "array form.array1"
   * if you want the combobox to assume the first
   * element in the array as the default:
   form.combobox1.value = form.array1[1]

The advantage of making the array a custom property of the form is that it goes away when the form does, and is always available to all controls in the form ...