Step 2 Set up the Combo Box

VLF Windows Application Development

Step 2. Set up the Combo Box

VFW050 – Basic Combo Box Processing

1.  On the Repository tab, find the file DEPTAB and drag and drop the fields DEPTDESC and then DEPTMENT onto the combo box.

     Adjust the Width of the Combo box so that the full description field is visible

2.  Columns within a list component are components which have their own properties, events and methods. Review the code you have generated for the combo box:

Define_Com Class(#PRIM_CMBX) Name(#CMBX_1) Componentversion(1) Displayposition(10) Height(18) Left(4) Parent(#BODY_HEAD) Showselection(False) Showselectionhilight(False) Tabposition(10) Top(211) Width(173)
Define_Com Class(#PRIM_CBCL) Name(#CBCL_1) Displayposition(1) Parent(#CMBX_1) Source(#DEPTDESC)
Define_Com Class(#PRIM_CBCL) Name(#CBCL_2) Displayposition(2) Parent(#CMBX_1) Source(#DEPTMENT)
 

     Component CBCL_1 is the first column of combo box CMBX_1. Note that CBCL_1 has a Parent of CMBX_1.

     The combo box can have only one visible column: the first column added. If you added DEPTMENT first, correct the set up by making the column containing DEPTMENT Visible false.

     In the Design view, to work with the combo box column 1, select the component CBCL_1 from the dropdown at the top of the Details tab.

3.  Create an  uInitialize method routine and add code to populate the combo box. The uInitialize method is already defined in the ancestor (VF_AC010).

     Your logic should clear the list CMBX_1 and select all valid department codes and descriptions from the table DEPTAB and add them to your combo box.

     Note that the CMBX_1 can be used as the Fields() parameter in I/O commands. Your code should look like the following:

Mthroutine name(uInitialize) Options(*REDEFINE)
Invoke Method(#Com_Ancestor.uInitialize)
Clr_List Named(#CMBX_1)
Select Fields(#CMBX_1) From_File(deptab)
Add_Entry To_List(#CMBX_1)
Endselect
Endroutine

 

4.  Since the Employee Details command handler is reading and updating an employee you need to ensure the combo box displays the required department description.

     Entries in a list components can be processed using the SELECTLIST/ENDSELECT loop.

5.  Add the following logic in the uExecute method routine, after the FETCH employee record.

Define Field(#deptw) Reffld(#deptment)
#deptw := #DEPTMENT
Selectlist Named(#CMBX_1)
Leave If(#DEPTMENT = #deptw)
Endselect
#CMBX_1.currentItem.focus := true

 

6.  How do you discover that the combo box has a currentitem which has a focus property?

     In the Design view, select the combo box and use the context menu on the combo box component and select Combo Box: CMBX_1 / Features.

     The Features help panel will be displayed.

7.  Expand the Properties to find CurrentItem. Note that the + symbol indicates that CurrentItem can be expanded.

8.  Double click on PRIM_CBIT to show the properties, events and methods for the list column component.

9.  Expand Properties to see the Focus property. Double click on the focus property to see the help for the CurrentItem.Focus Property.

10. Compile your component.