Step 1. Create Department Dropdown Reusable Part
VFW072 – Create a Department Dropdown Reusable Part
1. Create a new Reusable Part / Panel:
iiiVFW13
Department Dropdown
2. Resize the
so that it looks like the following:
a. Add a
to the panel.b. Select the DropDownList.
tab and change the property toc. Drop fields DEPTDESC and DEPTMENT into the
. If you add them in this order, you have created CBCL_1 sourced from DEPTDESC and CBCL_2 sourced from DEPTMENT.d. On the
tab, ensure the column sourced from DEPTMENT is selected. You can select any component within this reusable part from this dropdown.
e. Change its False. Only the column sourced from DEPTDESC should be visible in the combo box.
property tof. Resize the
so that it can display the full description.g. Move the Department.
to the right and add a component onto the left side of the . Give the a ofh. Resize the
, to fit the caption text and move it to the top left of the .Hint: An effective way to position a component in some cases, is to set its 0, will achieve the required result.
and properties. In this case, setting these toi. Set 150, and the 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.
property toj. 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
, 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
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.