Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Report control bug ?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Report control bug ?

 Post Reply Post Reply
Author
Message
Arnie View Drop Down
Newbie
Newbie


Joined: 04 March 2005
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote Arnie Quote  Post ReplyReply Direct Link To This Post Topic: Report control bug ?
    Posted: 18 March 2005 at 5:55am

Hi,

In my control the users can rightclick the column header and select remove column.
Lets say there were three columns with nItemIndex 0,1,2
The user removes the rightmost column.
After the column has been removed, the indexes are 0,1.

Then the user can add a new column.
Now the indexes are 0,1,3

When the rows are drawn in CXTPReportRow::Draw, the item is located:
CXTPReportRecordItem* pItem = m_pRecord->GetItem(pColumn);

Inside GetItem:

CXTPReportRecordItem* CXTPReportRecord::GetItem(CXTPReportColumn* pColumn)
{
if (this == NULL)
return NULL;
int nItemIndex = pColumn->GetItemIndex();
if (nItemIndex >= 0 && nItemIndex < GetItemCount())
{
return m_arrItems.GetAt(nItemIndex);
}
return NULL;
}

The problem is that for the last column with nItemindex 3, the item is not found in m_arrItems since it contains items in indexes 0,1,2.  The result is that this column only has blank items.

Any workaround/fix for this ?

Back to Top
Oleg View Drop Down
Admin Group
Admin Group
Avatar

Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 18 March 2005 at 7:21am

Seems you have bug in your code. There can't be situation with 0,1,3 indexes.

If  user remove column, m_bVisible of  CXTPReportColumn must be set as FALSE. it doen't remove from array of columns.

Please attach what additional code you added for Remove operation.

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Arnie View Drop Down
Newbie
Newbie


Joined: 04 March 2005
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote Arnie Quote  Post ReplyReply Direct Link To This Post Posted: 18 March 2005 at 8:02am

When i remove a column, i do:

CXTPReportColumns* pColumns = m_cGrid.GetColumns();
...Code to locate the correct column
pColumns->Remove(pColumn);

In CXTPReportColumns::Remove, the column is just removed from the array, the other columns indexes are not adjusted, so after remove, I can see in the debugger Watch window that
pColumns->m_arrColumns.m_pData[0].m_nItemIndex == 0
pColumns->m_arrColumns.m_pData[1].m_nItemIndex == 1
pColumns->m_arrColumns.m_pData[2].m_nItemIndex == 3

Back to Top
sserge View Drop Down
Moderator Group
Moderator Group


Joined: 01 December 2004
Status: Offline
Points: 1297
Post Options Post Options   Thanks (0) Thanks(0)   Quote sserge Quote  Post ReplyReply Direct Link To This Post Posted: 18 March 2005 at 10:12am
Arnie,

You should only locate the column and call pColumn->SetVisible(FALSE) in order to hide it.

Removing a column from the collection automatically means corresponding changes in the Report Record structure.

--
Regards,
Sergei
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down



This page was generated in 0.078 seconds.