Condividi tramite


Header Control and List Control

In most cases, you will use the header control that is embedded in a CListCtrl or CListView object. However, there are cases where a separate header control object is desirable, such as manipulating data, arranged in columns or rows, in a CView-derived object. In these cases, you need greater control over the appearance and default behavior of an embedded header control.

In the common case that you want a header control to provide standard, default behavior, you may want to use CListCtrl or CListView instead. Use CListCtrl when you want the functionality of a default header control, embedded in a list view common control. Use CListView when you want the functionality of a default header control, embedded in a view object.

Nota

These controls only include a built-in header control if the list view control is created using the LVS_REPORT style.

In most cases, the appearance of the embedded header control can be modified by changing the styles of the containing list view control. In addition, information about the header control can be obtained through member functions of the parent list view control. However, for complete control, and access, to the attributes and styles of the embedded header control, it is recommended that a pointer to the header control object be obtained.

The embedded header control object can be accessed from either CListCtrl or CListView with a call to the respective class's GetHeaderCtrl member function. The following code demonstrates this:

CHeaderCtrl* pHeaderCtrl = m_ListCtrl.GetHeaderCtrl();
ASSERT(NULL != pHeaderCtrl);
//perform any needed operations on the header using pHeader

What do you want to know more about?

See Also

Reference

Using CHeaderCtrl

Concepts

Controls (MFC)