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.
Subject |
Author |
Date |
|
David Skok
|
Sep 12, 2006 - 10:11 AM
|
I am using a CExtReportGridWnd in my project. So far I create the the CExtReportGridWnd and add columns and that’s all it displays for now. When I change context within my program I want to clear out the ReportGrid and fill it with new Rows, Columns and data. A while back I asked about this and you suggested the following to clear the ReportGrid:
LONG nColCount = wndGrid.ColumnCountGet(), nRowCount = wndGrid.RowCountGet(); if( nRowCount > 0 ) { wndGrid.SelectionUnset( false, false ); wndGrid.ReportItemUnRegisterSelection( false ); } wndGrid.SelectionUnset( false, false ); wndGrid.FocusUnset( false ); wndGrid.ReportColumnUnRegister( NULL, NULL, false );
ReportColumnUnRegister( NULL, NULL, true ) is not deleting the columns! They remain in the display when I add the new columns!!
============================= ALSO, Regarding Adding Rows: =============================
Your ReportGrid sample uses the following: CTypedPtrArray < CPtrArray, CExtReportGridItem * > arrRegisteredItems; arrRegisteredItems.SetSize( nRowCount );
I assume this creates nRowCount instances of CExtReportGridItem.
I tried the following (simplified):
CExtReportGridColumn *pRGC = ReportColumnRegister( _T("Preset"), _T("Presets"), true, false );
CExtReportGridItem *pRGI = new CExtReportGridItem();
pCell = ReportItemGetCell( pRGC, pRGI, RUNTIME_CLASS(CExtGridCellStringDM) );
It fails.
My report is populated with rows from an outside slow data source over a wire. I don’t know how many rows beforehand. If you could provide a simple example I would apreciate it.
One other thing. When oh when will updated help be ready. Reading headers and source to use all the stuff added since help was last updated is a pain!! Last I heard something new was supposed to be added in July then final in August.
|
|
David Skok
|
Sep 12, 2006 - 11:54 AM
|
I missed the code in the ASSERT following the CTypedPtrArray array code. I see that I should have used:
CExtReportGridItem *pRGI = ReportItemRegister();
It didn’t seem like SetSize was going going to do anything other than create an array of ptrs.
|
|
Suhai Gyorgy
|
Sep 13, 2006 - 3:19 AM
|
As for deletion, I use the following code for removing all rows: LONG nColCount = ColumnCountGet();
LONG nRowCount = RowCountGet();
if( nRowCount != 0 && nColCount != 0 ) {
SelectionUnset( false, false );
SelectionInsertAt( 0, CRect( 0, 0, nColCount - 1, nRowCount - 1 ), false );
ReportItemUnRegisterSelection(false);
}
As for deleting columns, I’d try this one: when registering all the columns, save them in a class variable CTypedPtrList < CPtrList, CExtReportGridColumn * > m_listColumns. Similar is done in ReportGrid sample. Then this code should work: POSITION pos = m_listColumns.GetHeadPosition();
CExtReportGridColumn * pRGC = NULL;
while( pos ) {
pRGC = m_listColumns.GetNext( pos );
ReportColumnUnRegister( pRGC, false );
}
m_listColumns.RemoveAll();
As for adding rows one by one, I use this code (simplified): CExtReportGridColumn * pRGC = NULL;
CExtReportGridItem * pRGI = NULL;
POSITION pos = NULL;
CExtGridCell * pCell = NULL;
bool bRowAvailable = ...;
while( bRowAvailable ) {
pRGI = ReportItemRegister();
ASSERT_VALID(pRGI);
pos = m_listColumns.GetHeadPosition();
// filling row’s first cell
pRGC = m_listColumns.GetNext( pos );
pCell = ReportItemGetCell( pRGC, pRGI, RUNTIME_CLASS(CExtGridCellNumber) );
ASSERT_VALID( pCell );
((CExtGridCellNumber*)pCell)->_VariantAssign( iSomeNumber, VT_UI4 );
...
// filling row’s second cell
pRGC = m_listColumns.GetNext( pos );
pCell = ReportItemGetCell( pRGC, pRGI, RUNTIME_CLASS(CExtGridCellStringDM) );
ASSERT_VALID( pCell );
...
}
|
|
David Skok
|
Sep 13, 2006 - 9:41 AM
|
Thank you for your suggestions however I have found that the library function ReportColumnUnRegister( pRGC ) does not work. Neither does ReportColumnUnRegisterCategory( __EXT_MFC_SAFE_LPCTSTR strCategoryName, bool bRedraw = true ); The latter even returns the correct amount of columns that it supposedly unregistered but they still display.
|
|
Technical Support
|
Sep 13, 2006 - 11:41 AM
|
We cannot confirm this problem. You can modify the CChildView::OnEditClear() method the ReportGrid sample, then compile and run it and hit Delete key in the report grid window: void CChildView::OnEditClear()
{
ReportColumnUnRegister(
_T("Name"),
_T("Main Information"),
true
);
return; You will see that the Name column is deleted correctly. Would you perform any similar modification of our sample to demostrate the problem?
|
|
David Skok
|
Sep 13, 2006 - 1:15 PM
|
I placed the following in CChildView::OnEditClear as you suggested:
void CChildView::OnEditClear() { if( RowCountGet() == 0 || ColumnCountGet() == 0 ) return;
LONG nColumns = ColumnCountGet();
ReportColumnUnRegister( _T("Name"), _T("Main Information"), true );
nColumns = ColumnCountGet();
return;
I deleted the registry entry for ReportGrids in order to start from scratch as I played with the sample alot and the column layout was not default. I run the sample, select an item, press DEL and the "Name" column remains!! Furthermore if I break and check nColumns it is the same number before and after ReportColumnUnRegister. From there the app is unstable, for instance if I try to drag "Name" column it asserts. It also asserts on close. This is the same way my own app behaves when deleting columns.
I use v2.54, VS2005, MBCS Debug. I did not edit any library code in any way.
|
|
Technical Support
|
Sep 14, 2006 - 10:21 AM
|
Thank you for reporting the bug. Please contact us via e-mail at support@prof-uis.com to get the fixed code.
|
|