Visual C++ and MFC Fundamentals Chapter 20: List-Based Controls
m_SampleFields.AddString(VideoCollection[i]);
}
else if( ItemSelected == "Categories" )
{
for(int i = 0; i < SizeCategories; i++)
m_SampleFields.AddString(Categories[i]);
}
else if( ItemSelected == "Authors" )
{
for(int i = 0; i < SizeAuthors; i++)
m_SampleFields.AddString(Authors[i]);
}
else if( ItemSelected == "Books" )
{
for(int i = 0; i < SizeBooks; i++)
m_SampleFields.AddString(Books[i]);
}
else // If we didn't create a list for the selected table, show nothing
m_SampleFields.ResetContent();
// Select the first item, if any, in the Sample Fields list box
m_SampleFields.SetCurSel(0);
}
- Test the program. Click different radio buttons and click different tables in the
Sample Tables list - Return to MSVC and design the dialog as follows:
- Add a new Static Text to the top right section of the dialog and set its caption to
Selected Fields - Add a new List Box under the Selected Fields label.