Objective Grid: Changing cell styles when using a browser grid

Article ID: 64
Last updated: 16 Apr, 2018
Article ID: 64
Last updated: 16 Apr, 2018
Revision: 3
Views: 1856
Posted: 12 Jan, 2001
by Meltreger B.
Updated: 16 Apr, 2018
by Meltreger B.

Problem


How do I change the styles for cells when using a browser grid? SetStyleRange() doesn't appear to be working?


Cause



Action


You can change the appearance of individual columns with

SetStyleRange(CGXRange().SetCols(nCol),
CGXStyle()
.SetHorizontalAlignment(DT_LEFT)
.SetInterior(RGB(255,0,0))
);

You might also format groups of cells by changing their base style.

Example:

BaseStyle(GetDaoParam()->m_bsNumeric).ChangeStyle(
CGXStyle()
.SetHorizontalAlignment(DT_LEFT)
.SetFont(CGXFont().SetFaceName("Courier New"))
, gxOverride);

But, you can't change the formatting of individual cells with SetStyleRange(). If you want to outline individual cells you need to override OnLoadCellStyle()

See "Outlining the row or column of the current cell with special formatting?".

The reason for this behavior is that if the grid would allow you to apply formatting with SetStyleRange(), they would be bound directly to the cell. But, what happens if there would have been rows inserted in the recordset, if the filter changes or if you do a requery? Most times, when you want to format cells in a DAO or ODBC Grid, it is because you want to outline depending on their context. And for outlining a cell on its context, overriding OnLoadCellStyle() and supply the cells formatting at runtime is the only way.

By the way, this behavior is also controlled through the CGXBrowseParam::m_bCanStoreGridCellInCGXData attribute. Take a look at the description of the CGXBrowseParam class.

This article was:   Helpful | Not helpful
Report an issue
Article ID: 64
Last updated: 16 Apr, 2018
Revision: 3
Views: 1856
Posted: 12 Jan, 2001 by Meltreger B.
Updated: 16 Apr, 2018 by Meltreger B.

Others in this category