![]() |
How to change parent of child records? |
Post Reply
|
| Author | |
kylechen
Groupie
Joined: 29 November 2004 Status: Offline Points: 57 |
Post Options
Thanks(0)
Quote Reply
Topic: How to change parent of child records?Posted: 10 December 2007 at 3:52am |
|
Hi there,
I'm using CXTPReportControl with one column displayed as a tree style. I need to change the child records' parent dynamically. My logic is:
CXTPReportRecord *pItem ; // the child item to move to new parent
CXTPReportRecord *pOldParent = pItem->GetRecords()->GetOwnerRecord() ;
CXTPReportRecord *pNewParent ; // the target record to hold the child
pOldParent->RemoveRecord(pItem) ;
pNewParent->Add(pItem) ;
However, when I call pOldParent->RemoveRecord(pItem), the pItem would be released by "InternalRelease" internally in CXTPReportControl~~~
Is there any easy way for this? Anyone can help will be much appreciated.
|
|
![]() |
|
kylechen
Groupie
Joined: 29 November 2004 Status: Offline Points: 57 |
Post Options
Thanks(0)
Quote Reply
Posted: 11 December 2007 at 8:04pm |
|
The solution is from Codejock support:- (For anyone has the same problem)
Can try using TreeAddRef() method before removing an item from an old parent.
For example, the following work in our sample for me: void CTreeViewDlg::OnOK() { CXTPReportRecord *pOldParent = m_wndReport.GetRecords()->GetAt(2); CXTPReportRecord *pItem = pOldParent->GetChilds()->GetAt(0) ; // the child item to move to new parent CXTPReportRecord *pNewParent = m_wndReport.GetRecords()->GetAt(0); // the target record to hold the child pItem->TreeAddRef(); pOldParent->GetChilds()->RemoveRecord(pItem); pNewParent->GetChilds()->Add(pItem); m_wndReport.Populate(); //CDialog::OnOK(); } Should be "InternalAddRef", there's no "TreeAddRef" in XTP 11.2.0 |
|
![]() |
|
Post Reply
|
|
|
Tweet
|
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |