Step 1 Create Department Dropdown Reusable Part

VLF Windows Application Development

Step 1. Create Department Dropdown Reusable Part

VFW072 – Create a Department Dropdown Reusable Part

1.  Create a new Reusable Part / Panel:

     Name: iiiVFW13

     Description: Department Dropdown

2.  Resize the Panel so that it looks like the following:

a.  Add a Combo box to the panel.

b.  Select the Details tab and change the ComboBoxStyle property to DropDownList.

c.  Drop fields DEPTDESC and DEPTMENT into the Combo box. If you add them in this order, you have created CBCL_1 sourced from DEPTDESC and CBCL_2 sourced from DEPTMENT.

d.  On the Details tab, ensure the column sourced from DEPTMENT is selected. You can select any component within this reusable part from this dropdown.

e.  Change its Visible property to False. Only the column sourced from DEPTDESC should be visible in the combo box.

f.  Resize the Combo box so that it can display the full description.

g.  Move the Combo box to the right and add a Label component onto the left side of the Panel. Give the Label a Caption of Department.

h.  Resize the Label, to fit the caption text and move it to the top left of the Panel.

     Hint: An effective way to position a component in some cases, is to set its Left and Top properties. In this case, setting these to 0, will achieve the required result.

i.  Set Combo box Left property to 150, and the Top property to 0. This will make the department dropdown component suitable for using alongside fields on a panel which is managed by a flow down manager.

j.  Resize the panel so that it uses the minimum space.

     Your design should now look like the following:

     The reusable part will occupy the space defined by its Panel, when you drop it onto your application form. It is important to minimize the space used by the reusable part, using the techniques shown above.

Note: You could also make this component more flexible by coding it to optionally hide the label and, if required, resize to display only the combo box.

3.  Create an Initialize event handling routine for the combo box. The logic in this routine should fill the combo box from the table DEPTAB and ensure that the focus is set to the first entry (if there was one). You code should look like the following:

Evtroutine Handling(#CMBX_1.Initialize) Options(*NOCLEARMESSAGES *NOCLEARERRORS)
Clr_List Named(#CMBX_1)
Select Fields(#CMBX_1) From_File(deptab)
Add_Entry To_List(#CMBX_1)
Endselect
Get_Entry Number(1) From_List(#CMBX_1)
If_Status Is(*okay)
#CMBX_1.currentItem.focus := true
Endif
Endroutine

 

     If you compiled your reusable part now, and added it to your command handler, it would contain data for all departments. However, it is not yet capable of interacting with your command handler.