A combo box control can allow the user to reorder columns by dragging a column header and dropping it at a new position. Column reordering is enabled or disabled using SetReorderColumns and is enabled by default. As column headers are used to drag a column, columns can only be reordered by the user if column headers are shown (see Column Headers).
A user drags a column by pressing the left mouse button on a column header and, without releasing the mouse button, moving the mouse cursor to a new location. A vertical bar indicates the position where the column will be inserted. Once the desired position is reached, the user releases the mouse button.
Columns can be reordered using the column headers of the dropdown portion or the column headers above the static portion or edit control portion. The new column order always applies to both portions. Reordering columns in the dropdown portion does not close the dropdown portion.
After the column order has changed, the parent window receives the SFTBOXN_REORDERED notification.
An application can define columns that must remain in their current position by adding SFTBOX_COL_KEEPPOS to the colFlag member of the column's SFTBOX_COLUMN structure. Such columns cannot be moved by the user.
Reordering columns is completely transparent to the application. An application always references columns and cells by the "real" column number, which is the column number used when the columns were defined with SetColumns. The real column number never changes, even if the column is displayed at a new position. See Display vs. Real Columns for more information.
In a simple combo box or dropdown combo box, the edit control portion displays the first displayed column if SetEditSearchColumn is set to -1. In this case, the column shown and searched by the edit control portion changes when another column is moved to the first position.
If an application wants to retain the column order between sessions, the dispPos member of the SFTBOX_COLUMN structure must be saved for each column, for example in response to the SFTBOXN_REORDERED notification. When the application is restarted and the combo box is initialized, the saved value is assigned to the dispPos member of each column before calling SetColumns.
case SFTBOXN_REORDERED: { LPSFTBOX_COLUMN lpCol; int c, nCols = SftBox_GetColumns(hwndBox, &lpCol); for (c = 0 ; c < nCols ; ++c) SaveColumnPosition(c, lpCol[c].dispPos); /* application function */ break; }