CGXGridCore::EnableGridToolTips
BOOL EnableGridToolTips(BOOL b = TRUE);
b
TRUE for enabling tool-tips; FALSE to turn them off.
Return Value
TRUE if tooltips are supported; FALSE if initialization failed.
Remarks
To enable tooltips for cells you have to call
EnableGridToolTips();
at initialization time of the grid (e.g., OnInitialUpdate or OnInitDialog).
You also have to register a user attribute that lets you specify the tooltip text for the cell.
The user attribute can be registered with
stylesmap = GetParam()->GetStylesMap();
// Tooltips
stylesmap->AddUserAttribute(GX_IDS_UA_TOOLTIPTEXT,
CGXStyle().SetWrapText(TRUE).SetAutoSize(TRUE));
You can then apply tooltips to specific cells with SetStyleRange.
Example:
SetStyleRange(CGXRange().SetCols(1), CGXStyle()
.SetUserAttribute(GX_IDS_UA_TOOLTIPTEXT, _T("Column 1")));
SetStyleRange(CGXRange().SetCols(2), CGXStyle()
.SetUserAttribute(GX_IDS_UA_TOOLTIPTEXT, _T("Column 2")));
SetStyleRange(CGXRange().SetCols(3), CGXStyle()
.SetUserAttribute(GX_IDS_UA_TOOLTIPTEXT, _T("Column 3")));
If you want to supply the tooltip information at run time, you should override GetStyleRowCol and call style.SetUserAttribute.
Note
Tooltips are only supported for MFC Version 4.0 or later!
Control Factory Specfic ->
You don't need to manually enable tool-tips for individual grids. If you select "Tool-tips" in the Objective Grid Build Wizard or Factory Wizard, tool-tips will be automatically enabled for all grids.
Also, the user attribute will automatically be registered.
END Control Factory Specfic
Example
This example shows you how enable tooltip support.
a) In a GridView
void CMyGridView::OnInitialUpdate()
{
EnableGridToolTips ();
...
}
b) From OnInitDialog in a dialog
BOOL CSample1Dialog::OnInitDialog()
{
CDialog::OnInitDialog();
GetGridWnd()->Initialize();
....
GetGridWnd()->EnableGridToolTips();
return TRUE; // return TRUE unless you set the focus to a control
}