Share via


Creating the List Control

OverviewSample

How the list control () is created depends on whether you're using the control directly or using class instead. If you use CListView, the framework constructs the view as part of its document/view creation sequence. Creating the list view creates the list control as well (the two are the same thing). The control is created in the view's handler function. In this case, the control is ready for you to add items, via a call to .

To use CListCtrl directly in a dialog box

  1. In the dialog editor, add a List Control to your dialog template resource. Specify its control ID.

  2. Use ClassWizard to add a member variable of type CListCtrl with the Control property. You can use this member to call CListCtrl member functions.

  3. Use ClassWizard to map handler functions in the dialog class for any list control notification messages you need to handle.

  4. In , set the styles for the CListCtrl. See Changing List Control Styles. This determines the kind of "view" you get in the control, although you can change the view later.

To use CListCtrl in a nondialog window

  1. Define the control in the view or window class.

  2. Call the control's member function, possibly in , possibly as early as the parent window's handler function (if you're subclassing the control). Set the styles for the control.

See Also   Windows Common Controls and MFC Classes