Compartir a través de


Adding Items to the Control

To add items to the list control (CListCtrl), call one of several versions of the InsertItem member function, depending on what information you have. One version takes a LV_ITEM structure that you prepare. Because the LV_ITEM structure contains numerous members, you have greater control over the attributes of the list control item.

Two important members (in regard to the report view) of the LV_ITEM structure are the iItem and iSubItem members. The iItem member is the zero-based index of the item the structure is referencing and the iSubItem member is the one-based index of a subitem, or zero if the structure contains information about an item. With these two members you determine, per item, the type and value of subitem information that is displayed when the list control is in report view. For more information, see CListCtrl::SetItem.

Additional members specify the item's text, icon, state, and item data. "Item data" is an application-defined value associated with a list view item. For more information about the LV_ITEM structure, see CListCtrl::GetItem.

Other versions of InsertItem take one or more separate values, corresponding to members in the LV_ITEM structure, allowing you to initialize only those members you want to support. Generally, the list control manages storage for list items, but you can store some of the information in your application instead, using "callback items." For more information, see Callback Items and the Callback Mask in this topic and Callback Items and the Callback Mask in the Windows SDK.

For more information, see Adding List-View Items and Subitems.

See Also

Reference

Using CListCtrl

Concepts

Controls (MFC)