You need to register new controls in the grid object (with CGXGridCore::RegisterControl) before using them as cell controls. You do this using a string resource identifier at run time. The name of the registered control will be displayed in the list box of the Controls page in the pre-built CGXStyleSheet dialog. It is not necessary to register existing Objective Grid controls. They are registered by the control factory as needed.
Follow these steps to register a control:
Add a string resource using Visual Studio Resource View by opening the string table in the resource file and adding your custom string resource. Your .RC - file will change accordingly:
STRINGTABLE DISCARDABLE BEGIN IDS_CTRL_BITMAP "Welcome bitmap" END |
In OnInitialUpdate(), pass a new instance of the object as well as the string resource ID to RegisterControl().
void CGridSampleView::OnInitialUpdate() { ... RegisterControl(IDS_CTRL_BITMAP, new CGXBitmapButton(this, IDB_WELCOME)); } |
// Snippet from gxfactry.cpp. This code demonstrates // the steps necessary when creating an instance of // CGXMaskControl case GX_IDS_CTRL_MASKEDIT: CGXMaskControl* pEditCtrl = new CGXMaskControl(pGrid, GX_IDS_CTRL_MASKEDIT); pEditCtrl->CreateControl(); pControl = pEditCtrl; break; // In contrast, here's the code necessary to create an // instance of CGXEditControl case GX_IDS_CTRL_EDIT: // default edit box pControl = new CGXEditControl(pGrid, GX_IDS_CTRL_EDIT); break; |
Now, apply the control to any cell in the grid with CGXStyle::SetControl().
// Display the welcome bitmap SetStyleRange(CGXRange(3, 2), CGXStyle() .SetControl(IDS_CTRL_BITMAP)); |
Copyright © Rogue Wave Software, Inc. All Rights Reserved.
The Rogue Wave name and logo, and Stingray, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.