HOWTO: Use BestFit() in tree like mode
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=18279
Printed Date: 29 September 2024 at 3:18am Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com
Topic: HOWTO: Use BestFit() in tree like mode
Posted By: mgampi
Subject: HOWTO: Use BestFit() in tree like mode
Date Posted: 27 April 2011 at 4:10am
Hi:
I can't figure out how to use CXTPReportHeader::BestFit() in tree-like control mode. It works very well in simple mode, but in tree-like mode with collapsed nodes the calculated column width is wrong. It seems as if only visible rows are considered. How can I calculate the required width over all rows whether they are collapsed or not? First expanding all nodes and then collapsing them again on startup/reload is no option because this would take a long time to process.
TIA
------------- Martin
Product: Xtreme Toolkit v 19.0.0, new Projects v 19.1.0 Platform: Windows 10 v 1909 (64bit) Language: VC++ 2017
|
Replies:
Posted By: ChrisBamford
Date Posted: 29 June 2011 at 5:34am
Hi, I have a similar issue to this with version 13.4.2.
I have a tree structure that can be up to 4 levels deep, e.g.:
Parent +- Child1 +- Child2 +- Child3 +- Child4
|
The issue for me is that after calling BestFit for all columns on a report control, the second column (which is the tree column, is not resized as I would expect. Following is an example screenshot.
Here is the code I'm using to call BestFit
CXTPReportColumns * pColumns = pthis->m_xtFileList.GetColumns(); pthis->m_xtFileList.GetReportHeader()->BestFit(pColumns->GetAt(1)); pthis->m_xtFileList.GetReportHeader()->BestFit(pColumns->GetAt(2)); pthis->m_xtFileList.GetReportHeader()->BestFit(pColumns->GetAt(3)); pthis->m_xtFileList.GetReportHeader()->BestFit(pColumns->GetAt(4));
|
pthis is a pointer to the current dialog.
And here is the code I'm using to create the columns:
m_xtFileList.AddColumn(new CXTPReportColumn(0, _T("Delete"), 20, TRUE, 0)); m_xtFileList.AddColumn(new CXTPReportColumn(1, _T("Filename"), 250, TRUE)); m_xtFileList.AddColumn(new CXTPReportColumn(2, _T("Type"), 125, TRUE)); m_xtFileList.AddColumn(new CXTPReportColumn(3, _T("Created"), 75, TRUE)); m_xtFileList.AddColumn(new CXTPReportColumn(4, _T("File Size"), 100, TRUE));
m_xtFileList.GetColumns()->Find(2)->SetTreeColumn(TRUE); m_xtFileList.GetColumns()->Find(0)->GetEditOptions()->m_bAllowEdit = FALSE; m_xtFileList.GetColumns()->Find(1)->GetEditOptions()->m_bAllowEdit = FALSE; m_xtFileList.GetColumns()->Find(2)->GetEditOptions()->m_bAllowEdit = FALSE; m_xtFileList.GetColumns()->Find(3)->GetEditOptions()->m_bAllowEdit = FALSE; m_xtFileList.GetColumns()->Find(4)->GetEditOptions()->m_bAllowEdit = FALSE; m_xtFileList.GetColumns()->Find(4)->SetAlignment(xtpColumnTextRight); m_xtFileList.GetColumns()->Find(4)->SetHeaderAlignment(DT_RIGHT);
m_xtFileList.GetReportHeader()->SetAutoColumnSizing(TRUE); m_xtFileList.GetReportHeader()->AllowColumnResize(TRUE); m_xtFileList.GetReportHeader()->AllowColumnRemove(FALSE); m_xtFileList.GetReportHeader()->AllowColumnReorder(FALSE); m_xtFileList.SetMultipleSelection(FALSE); m_xtFileList.FocusSubItems(FALSE); m_xtFileList.GetPaintManager()->SetColumnStyle(xtpReportColumnOffice2007); m_xtFileList.Populate();
|
Hopefully I've not broken any forum rules in this post. Many thanks for any help/advice that can be provided.
Chris.
|
Posted By: ChrisBamford
Date Posted: 30 June 2011 at 9:22am
Hi,
One work around I have found, which is not a perfect solution, is to find the deepest leaf in the tree and then add a child record to that leaf (call this pChild for example).
This helps force the column width of the parent record of pChild to be something more appropriate.
Thx, Chris.
|
Posted By: ABuenger
Date Posted: 30 June 2011 at 12:56pm
Hi Martin and Chris,
could you create a small sample that demonstrates your problem and then attach it to a new ticket or here?
Andre
------------- Codejock support
|
|