-
Here is an example project where one of the columns has a long caption. I did note that there is a header column height in pixels setting but this does not appear to be automatic.
TreeList does not provide such a functionality. The only possible way to achieve this goal is to manually calculate the required header height.
-
When the column header gets wrapped on to multiple lines does the number of lines or the height get reported somehow, i.e. can I read what the treeview column has done with the word wrapping?
-
Hi,
If your task is to calculate a column header height, you can do this by using the AppearanceObject.CalcTextSize method. You can review the How to enable the auto height feature for the column header panel, so the column header captions are shown in their entirety example where we described how to automatically adjust a column header height in a grid.
I hope that this information will help you resolve the issue.
-
Will that work for a TreeList too?
-
Yes, you can use the same approach. I have slightly modified the How to enable the auto height feature for the column header panel, so the column header captions are shown in their entirety example and attached it to John's answer.
-
I have had a look at the project supplied but it does not actually quite work right. The word 'Header' is missing?
-
Here is the fix to this problem, James:
private Size CalcCaptionTextSize(GraphicsCache cache, HeaderObjectInfoArgs ee, string caption) { Size captionSize = ee.Appearance.CalcTextSize(cache, caption, ee.CaptionRect.Width).ToSize(); Skin skin = GridSkins.GetSkin(treeList.LookAndFeel); SkinPaddingEdges edges = skin[GridSkins.SkinHeader].ContentMargins; captionSize.Height += edges.Top + edges.Bottom; captionSize.Width++; return captionSize; } -
The Plato that fixed it.
-
Actually there is some weird behaviour on this column header thing. If a column is resized within the viewable area of the tree list the height calculation miss-calculates for columns further along that are not in the current view but are still marked as Visible=true.
-
The TreeListViewInfo returns different dimentions depending on if the column header is in the current view or not. The x,y are 0,0 and the width is a difference of -5 when not in current view.
-
Hi James,
No, TreeList doesn't take into calculation columns that are not currently visible. That's why TreeListViewInfo returns empty bounds for them.
Thanks,
Vlad R -
The columns are marked visible just not in the current view because there are a lot of columns. I think the strange values I was seeing may be something to do with setting the VisibleIndex. I took the width of the column before setting VisibleIndex and then wrote back to the column width and it seems fine again. I think setting VisibleIndex breaks the column size properties.
-
James;
We will examine this behavior in detail and let you know what exactly causes this incorrect calculation. Please wait a bit. -
Thank you for your patience.
Use the following code to fix the issue:
private Size CalcCaptionTextSize(GraphicsCache cache, HeaderObjectInfoArgs ee, string caption) { ColumnInfo columnInfo = ee as ColumnInfo; Size captionSize = ee.Appearance.CalcTextSize(cache, caption, columnInfo.Column.Width).ToSize(); Skin skin = GridSkins.GetSkin(treeList.LookAndFeel); SkinPaddingEdges edges = skin[GridSkins.SkinHeader].ContentMargins; captionSize.Height += edges.Top + edges.Bottom; captionSize.Width++; return captionSize; } -
Hi, thanks for the reply. I still have a bit of an issue. Please see picture attached.
-
Thank you for your feedback. Change the implementation of the CalcCaptionTextSize method in the following code:
private Size CalcCaptionTextSize(GraphicsCache cache, HeaderObjectInfoArgs ee, string caption) { ColumnInfo columnInfo = ee as ColumnInfo; Skin skin = GridSkins.GetSkin(treeList.LookAndFeel); SkinPaddingEdges edges = skin[GridSkins.SkinHeader].ContentMargins; Size captionSize = ee.Appearance.CalcTextSize(cache, caption, columnInfo.Column.Width - edges.Left - edges.Right).ToSize(); captionSize.Height += edges.Top + edges.Bottom; captionSize.Width++; return captionSize; } -
Thanks Gosha that has fixed it.
-
You are welcome. Please feel free to contact us in case of any difficulty. We are happy to help you at any time.
There is a simple solution:
hide column, and treat first row as column.
then the problem is changed to : how to display multiple line in TreeList cell?
Sure you can find the answer.
-
The problem with this is that you will then loose the column header drag drop functionality which is a bit problematic and means you then have to implement more custom code to do your own drag drop of columns which means that the benefit of using the DevExpress control starts to fade.
-
Just an extra comment on this, the DevExpress controls have been and are really useful.
Is your intention to post an answer to your own question?
- If so, then proceed.
- If you simply wanted to post additional information, ask for further clarification, or to just say "Thanks!", please click Leave a Comment.
- If you wish to edit your original question, please use the Edit button in the Toolbox at the top right corner of that entry.
Facebook
Twitter
Google+