Visual C++ and MFC Fundamentals Chapter 20: List-Based Controls
// Get the number of items in the array
SizeBusiness = sizeof(Business) / sizeof(CString);
SizePersonal = sizeof(Personal) / sizeof(CString);
// Fill out the Sample Tables list with the Business items
for(int i = 0; i < SizeBusiness; i++)
m_SampleTables.AddString(Business[i]);
// Select the first item in the Sample Tables list box
m_SampleTables.SetCurSel(0);
return TRUE; // return TRUE unless you set the focus to a control
}
- Test your program
- After testing the dialog box, close it and return to MSVC.
- Add a BN_CLICKED Event Handler for the IDC_RDO_BUSINESS radio button
and change the name of the function to OnSelectBusiness - Add a BN_CLICKED Event Handler for the IDC_RDO_PERSONAL radio button
and change the name of the function to OnSelectPersonal - Implement both events as follows:
void CTableWizardDlg::OnSelectBusiness()
{
// TODO: Add your control notification handler code here
// Empty the list
m_SampleTables.ResetContent();
// Fill out the list with Business items
for(int i = 0; i < SizeBusiness; i++)
m_SampleTables.AddString(Business[i]);
// Select the first item in the list
m_SampleTables.SetCurSel(0);
}
void CTableWizardDlg::OnSelectPersonal()
{