+// ----------------------------------------------------------------------------
+// columns order
+// ----------------------------------------------------------------------------
+
+int wxListCtrl::GetColumnIndexFromOrder(int order) const
+{
+ const int numCols = GetColumnCount();
+ wxCHECK_MSG( order >= 0 && order < numCols, -1,
+ wxT("Column position out of bounds") );
+
+ wxArrayInt indexArray(numCols);
+ if ( !ListView_GetColumnOrderArray(GetHwnd(), numCols, &indexArray[0]) )
+ return -1;
+
+ return indexArray[order];
+}
+
+int wxListCtrl::GetColumnOrder(int col) const
+{
+ const int numCols = GetColumnCount();
+ wxASSERT_MSG( col >= 0 && col < numCols, wxT("Column index out of bounds") );
+
+ wxArrayInt indexArray(numCols);
+ if ( !ListView_GetColumnOrderArray(GetHwnd(), numCols, &indexArray[0]) )
+ return -1;
+
+ for ( int pos = 0; pos < numCols; pos++ )
+ {
+ if ( indexArray[pos] == col )
+ return pos;
+ }
+
+ wxFAIL_MSG( wxT("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,
+ wxT("wrong number of elements in column orders array") );
+
+ return ListView_SetColumnOrderArray(GetHwnd(), numCols, &orders[0]) != 0;
+}
+
+