Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Report Control
  New Posts New Posts RSS Feed - iterating items
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

iterating items

 Post Reply Post Reply
Author
Message
adico View Drop Down
Groupie
Groupie
Avatar

Joined: 20 April 2006
Location: United States
Status: Offline
Points: 23
Post Options Post Options   Thanks (0) Thanks(0)   Quote adico Quote  Post ReplyReply Direct Link To This Post Topic: iterating items
    Posted: 28 April 2006 at 12:04am
i am looking for a good example (vc++) on how to iterate through every single item(column) on a record (row).

i can get the row, but i want to scan every item & find out which item is empty (" ").


Thanx in advance

 
I am not my memories...I am my dreams!
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: 28 April 2006 at 3:47pm
Hi,

If you have a record pointer, you can iterate it in a very simple manner:

CXTPReportRecordItem* pItem = NULL;
for (int i = 0; i < pRecord->GetItemCount(); i++)
{
    pItem = pRecord->GetItem(i);
    if (pItem)
    {
        ASSERT(pItem->GetCaption(NULL).IsEmpty());
    }
}


--
WBR,
Serge
Back to Top
adico View Drop Down
Groupie
Groupie
Avatar

Joined: 20 April 2006
Location: United States
Status: Offline
Points: 23
Post Options Post Options   Thanks (0) Thanks(0)   Quote adico Quote  Post ReplyReply Direct Link To This Post Posted: 01 May 2006 at 11:03am
Sserge, thanx for your reply. However it doesn't seem to do what I want. Here is the code:

    CXTPReportRecordItem* pItem = NULL;
   CXTPReportRecord* pRecord =  (CXTPReportRecord*)m_wndReport.GetRecords();

    int nItemCnt = pRecord->GetItemCount();

    for(int i = 0; i < nItemCnt; i++)
    {
        pItem = pRecord->GetItem(i);
        if(pItem)   // IT NEVER GETS INSIDE HERE
        {
            ASSERT(pItem->GetCaption(NULL).IsEmpty());
        }
    }

it never gets inside the if(pItem) statement.

am i missing something?

Basically this is what I want to do: when the user clicks on a button, i want to get a total count of all the rows in the report. then starting with the first row, i want to iterate thru all the items & find out if there are any empty items. if so, i want to break out of the look & set focus (maybe change the cell color) to the first empty item.
I am not my memories...I am my dreams!
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: 01 May 2006 at 5:29pm
Your code above has an error. GetRecords() returns a collection of records, not just a single one. So far, to iterate all records and then items it would be:

    CXTPReportRecords* pRecords = wndReport.GetRecords();
    CXTPReportRecord* pRecord = NULL;

    int nRecordCnt = pRecords->GetCount();
    for(int i = 0; i < nRecordCnt; i++)
    {
        pRecord = pRecords->GetAt(i);
       
        // there goes my previous piece of code
        CXTPReportRecordItem* pItem = NULL;
        for (int j = 0; j < pRecord->GetItemCount(); j++)
        {
            pItem = pRecord->GetItem(j);
            if (pItem)
            {
                ASSERT(pItem->GetCaption(NULL).IsEmpty());
            }
        }       
    }


ps: by your description, you probably need to iterate ReportRows, and only then take and check a Record from a Row.

--
WBR,
Serge
Back to Top
adico View Drop Down
Groupie
Groupie
Avatar

Joined: 20 April 2006
Location: United States
Status: Offline
Points: 23
Post Options Post Options   Thanks (0) Thanks(0)   Quote adico Quote  Post ReplyReply Direct Link To This Post Posted: 01 May 2006 at 7:36pm
thanx sserge,

this does what i want (after some minor modifications).

could you elaborate (maybe provide an example) on what you mean by iterating ReportRows?

thnx


I am not my memories...I am my dreams!
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: 02 May 2006 at 5:21am
No problem, firstly look at help files to see the difference between Record and a Row.

Iterating difference is in their order. If you iterate Records, you'll take them in the order like you were adding them into the control. If you iterate Rows, they go in order like they're displayed.

Here is the example (add there NULL checks, etc):

CXTPReportRows* pRows = wndReport.GetRows();
for(int j = 0; j < pRows->GetCount(); j++)
{
    CXTPReportRow* pRow = pRows->GetAt(j);
    CXTPReportRecord* pRecord = pRow->GetRecord();
   
    for (int i = 0; i < pRecord->GetItemCount(); i++)
    {
        CXTPReportRecordItem* pItem = pRecord->GetItem(i);
        if (pItem)
        {
            ASSERT(pItem->GetCaption(NULL).IsEmpty());
        }
    }       
}


--
WBR,
Serge
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.203 seconds.