Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

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);
}


  1. Test the program. Click different radio buttons and click different tables in the
    Sample Tables list

  2. Return to MSVC and design the dialog as follows:

  3. Add a new Static Text to the top right section of the dialog and set its caption to
    Selected Fields

  4. Add a new List Box under the Selected Fields label.

Free download pdf