Collapse the table of content
Expand the table of content
The document is archived and information here might be outdated


Retrieves the column order (left to right) of a list view control.

BOOL GetColumnOrderArray(
   LPINT piArray,
   int iCount = -1 


A pointer to a buffer that will contain the index values of the columns in the list view control. The buffer must be large enough to contain the total number of columns in the list view control.
Number of columns in the list view control. If this parameter is -1, the number of columns is automatically retrieved by the framework.

Return Value

Nonzero if successful; otherwise zero.


This member function implements the behavior of the Win32 macro, ListView_GetColumnOrderArray, as described in the Platform SDK.


// The pointer to my list view control.
extern CListCtrl* pmyListCtrl;

// Reverse the order of the columns in the list view control
// (i.e. make the first column the last, the last column
// the first, and so on...).
CHeaderCtrl* pHeaderCtrl = pmyListCtrl->GetHeaderCtrl();

if (pHeaderCtrl != NULL)
   int  nColumnCount = pHeaderCtrl->GetItemCount();
   LPINT pnOrder = (LPINT) malloc(nColumnCount*sizeof(int));
   ASSERT(pnOrder != NULL);

   pmyListCtrl->GetColumnOrderArray(pnOrder, nColumnCount);

   int i, j, nTemp;
   for (i=0,j=nColumnCount-1;i < j;i++,j--)
      nTemp = pnOrder[i];
      pnOrder[i] = pnOrder[j];
      pnOrder[j] = nTemp;

   pmyListCtrl->SetColumnOrderArray(nColumnCount, pnOrder);

See Also

CListCtrl Overview | Class Members | Hierarchy Chart | CListCtrl::SetColumnOrderArray

© 2016 Microsoft