FILE: How to Populate a List or Combo Box with Recordset DataLast reviewed: March 5, 1998Article ID: Q182061 |
The information in this article applies to:
SUMMARYThe DaoDDX.exe sample demonstrates how to populate list and combo boxes with a column from a CDaoRecordset. The information this sample supplies can be used to provide the same functionality for Crecordset based objects. This sample uses two DDX functions to provide data exchange between the recordsets and the list and combo boxes.
MORE INFORMATIONThe following file is available for download from the Microsoft Software Library:
~ DaoDDX.exe (size: 610816 bytes)For more information about downloading files from the Microsoft Software Library, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q119591 TITLE : How to Obtain Microsoft Support Files from Online ServicesThis sample contains two DDX functions DDX_BindTextFieldListBoxToColumn() and DDX_BindTextFieldComboBoxToColumn() to link a particular column from a recordset to a list or combo box. These functions take the following parameters:
When saving, if the optional parameter to update the column is set, the function takes the current record, and updates the field in the column passed in with the currently selected item (or the modified text in a combo box situation). This method would be used in tables where the choices being given are not a foreign key. In the foreign key situation, which is the method used in the example, a second DDX function would be used to tie the selected value for that particular control to a field in the result set given. The function CDaoDDXView::PositionRecordsets() moves through the foreign recordsets, positioning each on the record denoted by the key value in the CDaoDDXView::m_pEnrollmentSet object. This allows the proper item to be selected in each of the controls, because the selection is based on the current record.
REFERENCESFor more information on how to write custom DDX and DDV functions, see technical note 26 in the Visual C++ documentation. For more information on using the CDaoRecordset and CRecordset classes, see the CDaoRecordset and CRecordset entries in the Visual C++ Class Library Reference.
|
Additional query words: CComboBox ClistBox combobox listbox
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |