Can I spread a title across two columns? I want it to look like this:
+---------+-------------+----------+---------+
| Item | Selection | Thing | Other |
| | First| Last | | |
+---------+------+------+----------+---------+
1 | | | | | |
+---------+------+------+----------+---------+
2 | | | | | |
+---------+------+------+----------+---------+
You can use a covered cell:
SetFrozenRows(1, 1);
SetCoveredCellsRowCol(0,1,0,2);
SetValueRange(CGXRange(0, 1), "Selection");
SetValueRange(CGXRange(1, 1), "First");
SetValueRange(CGXRange(1, 2), "Last");
Note:
If you want that when the user clicks on the column headers and selects columns, both columns "First" and "Last" should be selected when the user clicks on the "Selection" header, you should override CanChangeSelection.
If you have a covered row header for column 1 to 2, as in the above example you might override CanChangeSelection so that as soon as one of the column header cells is hit, both columns 1 and 2 will be selected.
Example:
BOOL CGridSampleView::CanChangeSelection(CGXRange* pRange, BOOL bIsDragging, BOOL bKey)
{
if (pRange)
{
CGXRange range;
if (range.IntersectRange(pRange, CGXRange().SetCols(1,2)))
pRange->UnionRange(*pRange, CGXRange(pRange->top, 1, pRange->bottom, 2));
}
return TRUE;
}
You might also consider call RowHeaderStyle().SetEnabled(FALSE) if you don't like the behavior that the row header can become the current cell (and therefore is then not drawn inverted).