Print Page | Close Window

[not bug] Report Control MoveRecord bug

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Report Control
Forum Description: Topics Related to Codejock Report Control
URL: http://forum.codejock.com/forum_posts.asp?TID=22644
Printed Date: 08 May 2024 at 5:43pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: [not bug] Report Control MoveRecord bug
Posted By: jmarcosf
Subject: [not bug] Report Control MoveRecord bug
Date Posted: 29 June 2015 at 2:35pm
I think there is a bug on MoveRecord() method on CXTPReportRecords class.
I commented out on source code below.

void CXTPReportRecords::MoveRecord(int nIndex, CXTPReportRecord* pRecord, BOOL bUpdateIndexes)
{
     if (nIndex < 0)
          nIndex = 0;

     if (nIndex > GetCount())
          nIndex = GetCount();

     if (pRecord)
     {
          int nRecordIndex = pRecord->GetIndex();

          if (nRecordIndex == nIndex)
               return;

          if (GetAt(nRecordIndex) == pRecord)
          {
               if (nRecordIndex < nIndex)          // I think this two sentences
                    nIndex--;                                // do not allow to move any record
                                                                   // one line down
               if (nRecordIndex == nIndex)       // Maybe I am wrong but
                    return;                                   // removing them it works fine for me
                                                                  // when I call it with index = current record index + 1
               m_arrRecords.RemoveAt(nRecordIndex);
               m_arrRecords.InsertAt(nIndex, pRecord);

               if (bUpdateIndexes)
                    UpdateIndexes();
          }
     }
}




Replies:
Posted By: olebed
Date Posted: 29 June 2015 at 3:55pm
Hi Jorge,

Logic of MoveRecord(nIndex, pRecord) is move pRecord to place BEFORE record with index nIndex. We follow this logic in other places in code, and we are not going to change MoveRecord().

If you delete those two conditions then method will work incorrect.
If nIndex is greater than index of pRecord
then pRecord will be placed AFTER record with nIndex
else
then pRecord will be placed BEFORE record with nIndex


Regards,
Oleksandr Lebed



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net