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 » How to remove all items from the ReportGrid? Collapse All
Subject Author Date
Khachatur Petrosyan Jun 26, 2007 - 5:02 AM

Hello,

I want to remove all items from the ReportGrid control.

class CMyGrid : public CExtPPVW < CExtReportGridWnd >
{
}

CMyGrid grid;
....
grid.RowRemoveAll();


When I call RowRemoveAll() function I receive an assertion in the CExtTreeGridDataProvider::RowRemove;


bool CExtTreeGridDataProvider::RowRemove(
    ULONG nRowNo,
    ULONG nRemoveCount // = 1
    )
{
    ASSERT_VALID( this );
    nRowNo;
    nRemoveCount;
    // this method must never be invoked
    ASSERT( FALSE );
    return false;
}


What is the right method of deleting all items from the ReportGrid control?

Thanks,
KP

Technical Support Jun 26, 2007 - 5:21 AM

You can also use the following code:

LONG nRowCount = m_wndGrid.RowCountGet();
if( nRowCount > 0L )
{
	HTREEITEM hRootItem = m_wndGrid.ItemGetRoot();
	ASSERT( hRootItem != NULL );
	if( hRootItem != NULL )
		m_wndGrid.ItemRemove( hRootItem, true, true );
}

Khachatur Petrosyan Jun 26, 2007 - 5:26 AM

This method works well.

Thanks,
KP

Suhai Gyorgy Jun 26, 2007 - 5:16 AM

In ReportGrid, rows are items and you insert them with ReportItemRegister.
So removing goes the other way around: you need to use ReportItemUnRegister.
But you should be calling this method to every item one by one, so it might be easier to programatically select all items/rows of the ReportGrid and use ReportItemUnRegisterSelection method instead of ReportItemUnRegister.