To get the number of columns in the list view control,
we first get a pointer to the header control and then use the header control
to query the number of columns it has.
CHeaderCtrl* pHeader = (CHeaderCtrl*) m_listctrl.GetDlgItem(0); int nColumnCount = pHeader->GetItemCount();
This works even when the listview control has the LVS_NOCOLUMNHEADER style.
It also works if the control is not in the report view.