Chapter 20: List-Based Controls Visual C++ and MFC Fundamentals
20.1 List Boxes.....................................................................................................
20.1.1..Overview...............................................................................................
A list box presents a list of items to choose from.
Each item displays on a line. The user makes a
selection by clicking in the list. Once clicked, the
item or line on which the mouse landed becomes
highlighted, indicating that the item is the current
choice. Once an item is selected, to make a different
selection, the user would click another. The user can
also press the up and down arrow keys to navigate
through the list and make a selection.
As far as item selection is concerned, there are two
types of list boxes: single selection and multiple
selection.
One of the main reasons for using a list box is to
display a list of items to the user. Sometimes the list would be very large. If the list is longer than the
available space on the control, the operating system would provide a scroll bar that allows the user to
navigate up and down to access all items of the list. Therefore, you will have the option of deciding how
many items to display on the list.
Practical Learning: Introducing List Boxes
- Start a new MFC Application named TableWizard
- Create it as Dialog Based and set the Dialog Title to Table Wizard
- On the Toolbox, click the Group Box control and click on the Top left section
of the dialog - Change its Caption to Categories
- On the Toolbox, click the Radio Button control and click in the group box on
the dialog box - Change its ID to IDC_RDO_BUSINESS and its Caption to &Business
- Check the Group property of the radio button or set this property to True
- Add a CButton Control Variable for IDC_RDO_BUSINESS. Name it
m_SelectBusiness - Add another radio button under the Business control. Change its ID to
IDC_RDO_PERSONAL ant its Caption to &Personal - Check the Group check box of the radio button or set the Group property to True
- Add a CButton Control Variable for the new radio button named
m_SelectPersonal