Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » obtaining row and column number Collapse All
Subject Author Date
Eric Houvenaghel Oct 20, 2006 - 2:22 PM

Hello

Basically, I want to use the GridCellSet function to destroy a cell.
The function takes row and column number as parameters.
I have the corresponding CExtReportGridItem and CExtReportGridColumn in the dataset.
How do I obtain the corresponding row and column numbers for the cell at CExtReportGridItem and CExtReportGridColumn postion as viewed on the screen?
Also, how do I recreate a cell at that spot and how do I destroy a cell that is hidden?

Thx

Technical Support Oct 21, 2006 - 11:26 AM

We added ReportItemSetCell() methods to the CExtReportGridDataProvider and CExtReportGridWnd classes:

    //////////////////////////////////////////////////////////////
    ///// DECLARATION IN SCOPE OF THE CExtReportGridDataProvider CLASS
    //////////////////////////////////////////////////////////////
    virtual bool ReportItemSetCell(
        const CExtReportGridColumn * pRGC,
        const CExtReportGridItem * pRGI,
        const CExtGridCell * pCellNewValue = NULL, // if NULL - empty existing cell values
        bool bReplace = false, // false - assign to existing cell instances or column/row type created cells, true - create new cloned copies of pCellNewValue
        CRuntimeClass * pInitRTC = NULL // runtime class for new cell instance (used if bReplace=false)
        );
    //////////////////////////////////////////////////////////////
    ///// IMPLEMENTATION
    //////////////////////////////////////////////////////////////
    bool CExtReportGridDataProvider::ReportItemSetCell(
        const CExtReportGridColumn * pRGC,
        const CExtReportGridItem * pRGI,
        const CExtGridCell * pCellNewValue, // = NULL // if NULL - empty existing cell values
        bool bReplace, // = false // false - assign to existing cell instances or column/row type created cells, true - create new cloned copies of pCellNewValue
        CRuntimeClass * pInitRTC // = NULL // runtime class for new cell instance (used if bReplace=false)
        )
    {
        ASSERT_VALID( this );
        if( pRGC == NULL || pRGI == NULL )
            return false;
        ASSERT_VALID( pRGC );
        ASSERT_VALID( pRGI );
        bool bActive = pRGC->ColumnIsActive();
        ULONG nColNo = 0;
        if( bActive )
        {
            nColNo = ActiveIndexGet( pRGC );
            if( nColNo == ULONG(-1L) )
                return NULL;
            ULONG nColCountInactive = InactiveColumnCountGet();
            nColNo += nColCountInactive;
        }
        else
        {
            nColNo = InactiveIndexGet( pRGC );
            if( nColNo == ULONG(-1L) )
                return NULL;
        }
        ASSERT( pRGI->TreeNodeGetParent() != NULL );
        ULONG nRowNo = pRGI->TreeNodeCalcOffset( false );
        CExtGridDataProvider & _DP = _Tree_GetCacheDP();
        ULONG nReservedColumnCount = 0, nReservedRowCount = 0;
        _DP.CacheReservedCountsGet( &nReservedColumnCount, &nReservedRowCount );
        nRowNo += nReservedRowCount;
        nColNo += m_nTreeReservedColumns;
        return
            _DP.CellRangeSet(
                nColNo,
                nRowNo,
                1L,
                1L,
                pCellNewValue,
                bReplace,
                pInitRTC,
                false,
                false
                );
    }
 

    //////////////////////////////////////////////////////////////
    ///// DECLARATION IN SCOPE OF THE CExtReportGridWnd CLASS
    //////////////////////////////////////////////////////////////
    virtual bool ReportItemSetCell(
        const CExtReportGridColumn * pRGC,
        const CExtReportGridItem * pRGI,
        const CExtGridCell * pCellNewValue = NULL, // if NULL - empty existing cell values
        bool bReplace = false, // false - assign to existing cell instances or column/row type created cells, true - create new cloned copies of pCellNewValue
        CRuntimeClass * pInitRTC = NULL // runtime class for new cell instance (used if bReplace=false)
        );
    bool ReportItemSetCell(
        __EXT_MFC_SAFE_LPCTSTR strColumnName,
        __EXT_MFC_SAFE_LPCTSTR strCategoryName,
        const CExtReportGridItem * pRGI,
        const CExtGridCell * pCellNewValue = NULL, // if NULL - empty existing cell values
        bool bReplace = false, // false - assign to existing cell instances or column/row type created cells, true - create new cloned copies of pCellNewValue
        CRuntimeClass * pInitRTC = NULL // runtime class for new cell instance (used if bReplace=false)
        );
    //////////////////////////////////////////////////////////////
    ///// IMPLEMENTATION
    //////////////////////////////////////////////////////////////
    bool CExtReportGridWnd::ReportItemSetCell(
        const CExtReportGridColumn * pRGC,
        const CExtReportGridItem * pRGI,
        const CExtGridCell * pCellNewValue, // = NULL // if NULL - empty existing cell values
        bool bReplace, // = false // false - assign to existing cell instances or column/row type created cells, true - create new cloned copies of pCellNewValue
        CRuntimeClass * pInitRTC // = NULL // runtime class for new cell instance (used if bReplace=false)
        )
    {
        ASSERT_VALID( this );
        if( pRGC == NULL || pRGI == NULL )
            return false;
        ASSERT_VALID( pRGC );
        ASSERT_VALID( pRGI );
        CExtReportGridDataProvider & _DP = _GetReportData();
        bool bRetVal =
            _DP.ReportItemSetCell(
                pRGC,
                pRGI,
                pCellNewValue,
                bReplace,
                pInitRTC
                );
        return bRetVal;
    }
    bool CExtReportGridWnd::ReportItemSetCell(
        __EXT_MFC_SAFE_LPCTSTR strColumnName,
        __EXT_MFC_SAFE_LPCTSTR strCategoryName,
        const CExtReportGridItem * pRGI,
        const CExtGridCell * pCellNewValue, // = NULL // if NULL - empty existing cell values
        bool bReplace, // = false // false - assign to existing cell instances or column/row type created cells, true - create new cloned copies of pCellNewValue
        CRuntimeClass * pInitRTC // = NULL // runtime class for new cell instance (used if bReplace=false)
        )
    {
        ASSERT_VALID( this );
        CExtReportGridColumn * pRGC = ReportColumnGet( strColumnName, strCategoryName );
        bool bRetVal =
            ReportItemSetCell(
                pRGC,
                pRGI,
                pCellNewValue,
                bReplace,
                pInitRTC
                );
        return bRetVal;
    }


Suhai Gyorgy Oct 20, 2006 - 4:16 PM

I’d try calling CExtReportGridWnd::ReportItemGetCell first and then call calling CExtGridCell::OnHitTestInfoAdjust on the resulting cell. But CExtGridCell::OnHitTestInfoAdjust might be private function, I can’t check right now. If it is private... I don’t have any other idea now.