SetAutoColumnSizing problem |
Post Reply |
Author | |
znakeeye
Senior Member Joined: 26 July 2006 Status: Offline Points: 1672 |
Post Options
Thanks(0)
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/
|
|
znakeeye
Senior Member Joined: 26 July 2006 Status: Offline Points: 1672 |
Post Options
Thanks(0)
|
Also, setting bAutoSize=1 in the CXTPReportColumn constructor yields a column which cannot be resized! That cannot be right!
|
|
PokerMemento - http://www.pokermemento.com/
|
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
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!)
|
|
znakeeye
Senior Member Joined: 26 July 2006 Status: Offline Points: 1672 |
Post Options
Thanks(0)
|
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/
|
|
znakeeye
Senior Member Joined: 26 July 2006 Status: Offline Points: 1672 |
Post Options
Thanks(0)
|
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/
|
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
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. |
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
>>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
|
|
znakeeye
Senior Member Joined: 26 July 2006 Status: Offline Points: 1672 |
Post Options
Thanks(0)
|
Thanks. I solved it by deriving CXTPReportHeader and handling OnColumnChanged. Before I call the base I modify my columns :)
|
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
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
|
|
znakeeye
Senior Member Joined: 26 July 2006 Status: Offline Points: 1672 |
Post Options
Thanks(0)
|
Sounds like a great idea.
|
|
znakeeye
Senior Member Joined: 26 July 2006 Status: Offline Points: 1672 |
Post Options
Thanks(0)
|
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/
|
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
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
|
|
znakeeye
Senior Member Joined: 26 July 2006 Status: Offline Points: 1672 |
Post Options
Thanks(0)
|
Good to hear.
I'll play a bit with your mod until then. Thanks.
|
|
PokerMemento - http://www.pokermemento.com/
|
|
znakeeye
Senior Member Joined: 26 July 2006 Status: Offline Points: 1672 |
Post Options
Thanks(0)
|
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/
|
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
OK but what do you think about app I asked you to take a look?
|
|
SuperMario
Admin Group Joined: 14 February 2004 Status: Offline Points: 18057 |
Post Options
Thanks(0)
|
Did Mark's solution resolve your problem?
|
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
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 |
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
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
|
|
znakeeye
Senior Member Joined: 26 July 2006 Status: Offline Points: 1672 |
Post Options
Thanks(0)
|
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/
|
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
You can also prevent such action for last column is you don't want it
|
|
znakeeye
Senior Member Joined: 26 July 2006 Status: Offline Points: 1672 |
Post Options
Thanks(0)
|
What happened to the SetLastColumnExpand function? Will it be added in 14.x?
|
|
PokerMemento - http://www.pokermemento.com/
|
|
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 |