Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Report Control
  New Posts New Posts RSS Feed - SetAutoColumnSizing problem
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

SetAutoColumnSizing problem

 Post Reply Post Reply
Author
Message
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 Topic: SetAutoColumnSizing problem
    Posted: 30 August 2009 at 8:33am
I don't want my columns to be auto-sized except for the last one!
 
GetReportHeader()->SetAutoColumnSizing(FALSE);
 
That has no effect as far as I can tell. Bug?
 
So I tried creating all my columns with bAutoSize = 0. That worked, except that the last column is not auto-sized. (And since I allow reordering of columns, I cannot create a rule for the bAutoSize-flag).
 
That is, when I resize my report control I don't want any of the columns to be affected except the last one, which shall fill the rest of the space. (Quite reasonable.)
 
A bug or a missing feature? I really need this though. Any chance you can fix it?
PokerMemento - http://www.pokermemento.com/
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: 30 August 2009 at 9:01am
Also, setting bAutoSize=1 in the CXTPReportColumn constructor yields a column which cannot be resized! That cannot be right!
PokerMemento - http://www.pokermemento.com/
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 30 August 2009 at 12:55pm
You need to call Col->SetAutoSize(FALSE) for each column Col except the last.
 
Initial bAutoSize assigned in constructor to two different flags - m_bAutoSize = bAutoSize and m_bIsResizable = bAutoSize
We need to set column resizable for user (keep m_bIsResizable = TRUE) and not for form resizing (set m_bAutoSize = FALSE)
 
Now your last column will fill all feasible report width
 
It also make sense to set pCol->SetMinWidth(...) for your last column - it will prevent making this column too narrow and force to use scrollbar 
 
Try this sample - e.g. I can resize this till the end of my second monitor and have last column to use 1.5 screens
 
 
btw - this sample also demonstrate multi-level virtual tree - use menu - Report - Simple 1-tree (obsolete title!)
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: 31 August 2009 at 5:16am
Looks promising, but just like I said; reordering the columns breaks this.
 
If you move your last column to the left, you get strange behavior when resizing.
PokerMemento - http://www.pokermemento.com/
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: 31 August 2009 at 9:50am
An idea is to handle XTP_NM_REPORT_COLUMNORDERCHANGED, but what if I hide/remove the last column? It soon becomes too many cases to take care of...
PokerMemento - http://www.pokermemento.com/
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 31 August 2009 at 10:01am
Use nmData.nReason

xtpReportColumnChangeOther = 0x0000, // Neither column order nor group order is changed.

xtpReportColumnOrderChanged = 0x0001, // Column order changed.

xtpReportColumnGroupOrderChanged = 0x0002, // Group order changed.

xtpReportColumnAdded = 0x0010, // A column is added to the column list.

xtpReportColumnRemoved = 0x0020, // A column is removed from the column list.

xtpReportColumnWidthChanged = 0x0100, // The column width is changed.

xtpReportColumnShown = 0x0200, // A column visibility property is changed to "visible".

xtpReportColumnHidden = 0x0400, // A column visibility property is changed to "hidden".

xtpReportColumnMoved = 0x0800, // A column is moved.

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

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 31 August 2009 at 10:25am
>>Looks promising, but just like I said; reordering the columns breaks this
It is not break - it just resized moved column and keep other untouched - sometimes this is a logical feature - your initial last column has long strings with needed info (say reason of some modificaitions) but you want to move it near another column (say timestamp) to have more information together
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: 01 September 2009 at 2:58am
Thanks. I solved it by deriving CXTPReportHeader and handling OnColumnChanged. Before I call the base I modify my columns :)
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 02 September 2009 at 10:32am
What do you think about adding a special flags:
 
private m_bLastColumnExpand and m_bLastColumnExpandKeep with public SetLastColumnExpand(BOOL, BOOL) function to do all job with other columns to prepare such mode?
 
We can also use this setter on OnColumnChanged event in BASE class if second flag set to TRUE
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: 02 September 2009 at 10:52am
Sounds like a great idea.
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: 11 September 2009 at 5:45pm
Can't find SetLastColumnExpand in 13.2 beta
 
How am I supposed to test it? Will it be implemented in 13.2 release?
PokerMemento - http://www.pokermemento.com/
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 14 September 2009 at 6:14pm
You can try new demo app https://forum.codejock.com/uploads/DemoVersion/ReportPaneViewTrackStaticMod.rar
 
It show some extention or your case - e.g. first columns - fixed and you can resize this columns and scrollbar will react on this. Last column - autozised and grow or shrink with form. You can also resize rows (same as columns) - select row and use tracker (up-down)
 
I still not implemented SetLastColumnExpand but hope to do it before oficial release
 
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: 15 September 2009 at 3:10am
Good to hear.
 
I'll play a bit with your mod until then. Thanks.
PokerMemento - http://www.pokermemento.com/
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: 15 September 2009 at 3:49pm
I really hope this feature gets into 13.2 :)
I'm planning a big release with this version, and this is one of the remaining items I want to get fixed.
PokerMemento - http://www.pokermemento.com/
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 15 September 2009 at 3:52pm
OK but what do you think about app I asked you to take a look?
Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post Posted: 18 September 2009 at 12:40pm
Did Mark's solution resolve your problem?
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 18 September 2009 at 2:09pm
This is as simple as possible - check https://forum.codejock.com/uploads/DemoVersion/ReportSampleStatic.rar 
and inside rinning app use menu - Report Control - Control Test - Task List sample
 
this is the code in the end of int CTaskListView::OnCreate(LPCREATESTRUCT lpCreateStruct) function

.......................................................................................

wndReport.Populate();

wndReport.SetFocus();

//----------------------------------------------------------------------------

wndReport.GetReportHeader()->SetAutoColumnSizing(FALSE);

int nColumnsCount = wndReport.GetColumns()->GetCount(), nColumn;

for (nColumn = 0; nColumn < nColumnsCount; nColumn++)

{

CXTPReportColumn* pColumn = wndReport.GetColumns()->GetAt(nColumn);

if (pColumn && pColumn->IsVisible())

pColumn->SetAutoSize(FALSE);

}

wndReport.GetColumns()->GetLastVisibleColumn()->SetAutoSize(TRUE);

wndReport.GetReportHeader()->SetAutoColumnSizing(TRUE);

//----------------------------------------------------------------------------

return 0;

}

Please play now with this TaskListView - resize form and see reaction - all columns untouched and last one will take all possible space
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 18 September 2009 at 2:34pm
I packed this piece of code into void CXTPReportHeader::SetLastColumnExpand(BOOL bLastColumnExpand, BOOL bLastColumnExpandKeep) function
 
see result in same sample in main sample view - try to resize and also drag and drop last column on other place -
it will keep get all resizing resources while other columns keep same width
 
 
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: 21 September 2009 at 10:12am
Sure, but beware of user actions such as "Hide/show/move/remove column". If the last column is hidden, the second last column becomes the last one. So this setting must actively adapt to the column count/order!
PokerMemento - http://www.pokermemento.com/
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 21 September 2009 at 10:19am
You can also prevent such action for last column is you don't want it
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: 04 May 2010 at 6:34am
What happened to the SetLastColumnExpand function? Will it be added in 14.x?
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.