Kbase 17782: How To Link CSCombo Control With A DB Field?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  10/16/2008 |
|
Status: Unverified
GOAL:
How To Link CSCombo Control With A DB Field?
FIX:
How to associate the CSCombobox ActiveX control with a database field, and how to use the control to change the data in an underlying field.
The following example is for a SmartViewer displaying fields from the Customer table of the Sports database, with the CSCombobox control associated with the Sales-Rep field of the Customer table.
1. Create a SmartViewer and drop database fields from the Customer table onto the SmartViewer.
2. Choose the CSCombobox ActiveX control from the UIB palette and place it onto the SmartViewer.
3. To populate the CSCombobox control with the possible values for Customer.Sales-Rep, create local ADM event procedure local-initialize and add the following code after the standard behavior:
FOR EACH Salesrep NO-LOCK:
chCtrlFrame:CSComboBox:AddItem(sports.Salesrep.Sales-Rep).
END.
4. To display the value of Customer.Sales-Rep in the Combobox control, create local ADM event procedure local-display-fields and add the following code after the standard behavior:
DO WITH FRAME {&FRAME-NAME}:
IF AVAILABLE Customer THEN
ASSIGN chCtrlFrame:CSComboBox:VALUE = sports.Customer.Sales-Rep.
END.
5. To assign the value of the Combobox control to the database field, create local ADM event procedure local-assign-record and add the following code after the standard behavior:
ASSIGN sports.Customer.Sales-Rep=STRING(chCtrlFrame:CSComboBox:VALUE).
When this SmartViewer is run in a SmartWindow and is linked to an update SmartPanel, the CSCombobox control can be used to change the value of Customer.Sales-Rep in the database.