Can I spread a title across two columns?

Article ID: 477
Last updated: 25 Apr, 2018
Article ID: 477
Last updated: 25 Apr, 2018
Revision: 3
Views: 2485
Posted: 11 Jan, 2001
by Meltreger B.
Updated: 25 Apr, 2018
by Meltreger B.

Problem

 


Can I spread a title across two columns? I want it to look like this:

Item

Selection

Other

First

Last

1

2

 

 


Cause

 


 

 


Action

 


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 calling 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).

This article was:   Helpful | Not helpful
Report an issue
Article ID: 477
Last updated: 25 Apr, 2018
Revision: 3
Views: 2485
Posted: 11 Jan, 2001 by Meltreger B.
Updated: 25 Apr, 2018 by Meltreger B.

Others in this category