+// ----------------------------------------------------------------------------
+// columns order
+// ----------------------------------------------------------------------------
+
+int wxListCtrl::GetColumnOrder(int col) const
+{
+ const int numCols = GetColumnCount();
+ wxCHECK_MSG( col >= 0 && col < numCols, -1, _T("Col index out of bounds") );
+
+ wxArrayInt indexArray(numCols);
+
+ if ( !ListView_GetColumnOrderArray(GetHwnd(), numCols, &indexArray[0]) )
+ return -1;
+
+ return indexArray[col];
+}
+
+int wxListCtrl::GetColumnIndexFromOrder(int order) const
+{
+ const int numCols = GetColumnCount();
+ wxASSERT_MSG( order >= 0 && order < numCols, _T("Col order out of bounds") );
+
+ wxArrayInt indexArray(numCols);
+
+ if ( !ListView_GetColumnOrderArray(GetHwnd(), numCols, &indexArray[0]) )
+ return -1;
+
+ for ( int col = 0; col < numCols; col++ )
+ {
+ if ( indexArray[col] == order )
+ return col;
+ }
+
+ wxFAIL_MSG( _T("no column with with given order?") );
+
+ return -1;
+}
+
+// Gets the column order for all columns
+wxArrayInt wxListCtrl::GetColumnsOrder() const
+{
+ const int numCols = GetColumnCount();
+
+ wxArrayInt orders(numCols);
+ if ( !ListView_GetColumnOrderArray(GetHwnd(), numCols, &orders[0]) )
+ orders.clear();
+
+ return orders;
+}
+
+// Sets the column order for all columns
+bool wxListCtrl::SetColumnsOrder(const wxArrayInt& orders)
+{
+ const int numCols = GetColumnCount();
+
+ wxCHECK_MSG( orders.size() == (size_t)numCols, false,
+ _T("wrong number of elements in column orders array") );
+
+ return ListView_SetColumnOrderArray(GetHwnd(), numCols, &orders[0]) != 0;
+}
+
+