In a combo box control with multiple columns, the contents of a cell can merge into the adjacent cell on the right, including the cell colors, font and picture. If that cell is empty, i.e., it has no cell text or picture, the cell immediately to its left uses the additional space to display its contents.
Cell merging is defined for columns, using the colFlag member of the SFTBOX_COLUMN structure (see SetColumns):
| SFTBOX_COL_MERGE | The cells of this column can merge into the next displayed column, if the cell in the next column is empty and the next column allows being merged into. |
| SFTBOX_COL_MERGEINTO | The cells of the previous column can merge into this column, if the cell in this column is empty. |
Both columns have to be defined suitably. In this example, a long description in column 0 uses the space of column 1 for all items that have no text in column 1:
LPSFTBOX_COLUMN lpCol; int nCols = SftBox_GetColumns(hwndBox, &lpCol); lpCol[0].colFlag |= SFTBOX_COL_MERGE; /* column 0 can merge into the next column */ lpCol[1].colFlag |= SFTBOX_COL_MERGEINTO; /* column 1 accepts the contents of column 0 */ SftBox_SetColumns(hwndBox, nCols, lpCol);
![]() | ![]() |
| Without cell merging | With cell merging |
A cell is merged only while the cell to its right is empty. Once cell text or a cell picture is assigned to that cell (using SetText or SetCellInfo), both cells are displayed normally.
Column headers also use these settings. If a column defined using SFTBOX_COL_MERGEINTO has no header text and no header picture and the previous column is defined using SFTBOX_COL_MERGE, the column headers merge. If the columns are resizable, a small resizing handle is shown in the combined column header.
Cell merging applies to the dropdown portion and, in a dropdown list combo box, to the selected item displayed in the static portion.