Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Report Control
  New Posts New Posts RSS Feed - HOWTO: Use BestFit() in tree like mode
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

HOWTO: Use BestFit() in tree like mode

 Post Reply Post Reply
Author
Message
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1198
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post Topic: HOWTO: Use BestFit() in tree like mode
    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
Back to Top
ChrisBamford View Drop Down
Newbie
Newbie


Joined: 02 February 2011
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote ChrisBamford Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
ChrisBamford View Drop Down
Newbie
Newbie


Joined: 02 February 2011
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote ChrisBamford Quote  Post ReplyReply Direct Link To This Post 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.

Back to Top
ABuenger View Drop Down
Newbie
Newbie
Avatar

Joined: 02 February 2006
Status: Offline
Points: 1075
Post Options Post Options   Thanks (0) Thanks(0)   Quote ABuenger Quote  Post ReplyReply Direct Link To This Post 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
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.172 seconds.