Hi, I'm trying to list all the data from a field in an mdb database in a combo box, on a property page. I'm using MFC and I have some code to populate a combo box from a database on the main form. Where do I put most of the code, as a CPropertyPage doesnt have an OnInitialUpdate() function, which is where all the examples I have seen are, do I put it immediately after the page is created on the sheet in the MyFormView.cpp file? Or in the MyPropertyPage.cpp file? The database is quite large so I would prefer to use a seperate recordset for each table.
m_pCustomersSet is a pointer to my seperate Customers recordset
CL1_2Customers is my PropertyPage
m_CustomerList is the my CComboBox variable
I have used OnSetActive in place of the normal OnInitialUpdate because as far as I can tell it is the closest equivalent in property pages.Code:UINT CL1_2Customers::PopulateCustomerList() { UINT nCount = 0; ASSERT( m_pCustomersSet->IsOpen() == TRUE); if( !m_pCustomersSet->IsBOF() )// if customer table is not currently at the beginning of the file { m_CustomerList.ResetContent(); //reset the combo box m_pCustomersSet->MoveFirst(); //Move to the first record while( !m_pCustomersSet->IsEOF() ) //While the current record is not the last record { m_CustomerList.AddString( m_pCustomersSet->m_CCompany_Name ); //Add the Company name for the current record m_pCustomersSet->MoveNext(); // Move to the next record nCount++; //count the total number of records added } } return nCount; } BOOL CL1_2Customers::OnSetActive() { CTykeDoc* pDoc = (CTykeDoc*)IsKindOf(RUNTIME_CLASS(CTykeDoc)); //** get pointers to the recordsets m_pCustomersSet = pDoc->m_pCustomersSet; UINT nCustomerCount = PopulateCustomerList(); if( nCustomerCount > 0 ) { this->m_CustomerList.SetCurSel( 0 ); } return CPropertyPage::OnSetActive(); }