Getting the number of columns in the report view

CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.


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.

 

More by Author

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Must Read