Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Report Control
  New Posts New Posts RSS Feed - Move Up/Down records
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Move Up/Down records

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


Joined: 17 February 2009
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote Sudhakar Quote  Post ReplyReply Direct Link To This Post Topic: Move Up/Down records
    Posted: 11 March 2009 at 4:25am
I have below code in a button("Move Up" ) handler. I need to move the record whenever the user clicks the "Move Up" button after selecting a report control row. Below code is not moving the record up. The focus(selection) just moving up, but the data of the selected record is not moving up. What could be the problem? Please suggest.
 

void CPVRuleManagerDlg::OnBnClickedMoveup()
{
  CXTPReportRow *pSelRow = m_wndReportCtrl.GetFocusedRow();
  if( pSelRow != NULL )
  {
    int index = pSelRow->GetIndex();
    CXTPReportRow *pRow = m_wndReportCtrl.GetRows()->GetAt(index);
    if(pRow)
    {
      pRow->InternalAddRef();
      m_wndReportCtrl.GetRows()->RemoveAt(index);
      m_wndReportCtrl.GetRows()->InsertAt(index-1,pRow);
      m_wndReportCtrl.RedrawControl();
      m_wndReportCtrl.SetFocus();
    }
  }
  m_wndReportCtrl.Populate();
}

Back to Top
Sudhakar View Drop Down
Newbie
Newbie


Joined: 17 February 2009
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote Sudhakar Quote  Post ReplyReply Direct Link To This Post Posted: 14 March 2009 at 11:21am

Somehow I got the solution. It works with CXTPReportRecord instead of CXTPReportRow.

 void CPVRuleManagerDlg::OnBnClickedMoveup()
 {
  CXTPReportRow *pSelRow = m_wndReportCtrl.GetFocusedRow();
  if( pSelRow != NULL )
  {
    int index = pSelRow->GetIndex();

    if( index== 0)
      return;

    CXTPReportRecord *pRecord = m_wndReportCtrl.GetRecords()->GetAt(index);
    if(pRecord)
    {
      pRecord->InternalAddRef();
      m_wndReportCtrl.GetRecords()->RemoveAt(index);
      m_wndReportCtrl.GetRecords()->InsertAt(index-1,pRecord);

      m_wndReportCtrl.Populate();
      m_wndReportCtrl.SetFocus();
    }
  }
}

Back to Top
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post Posted: 19 March 2009 at 7:30am
Perhaps you should read this thread: http://forum.codejock.com/forum_posts.asp?TID=13113
PokerMemento - http://www.pokermemento.com/
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.