Current filter:
                                You should refresh the page.
                                0
                                  • I have enabled word wrap on the column header of a TreeList but how to I get the column to auto-resize? I am manually adjusting the row heights but want just the column header height to auto-size.

                                • James Austin 06.25.2012

                                  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.

                                You must  log in  or  register  to leave comments

                                2 Solutions

                                Creation Date
                                Rating
                                Importance
                                Sort by
                                1

                                TreeList does not provide such a functionality. The only possible way to achieve this goal is to manually calculate the required header height.

                                dxSample.zip
                                Show all comments
                                • James Austin 06.26.2012

                                  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.

                                • James Austin 06.28.2012

                                  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.

                                • James Austin 07.02.2012

                                  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;
                                          }
                                  
                                • James Austin 07.03.2012

                                  The Plato that fixed it.

                                • James Austin 07.11.2012

                                  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.

                                • James Austin 07.11.2012

                                  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.

                                • Vlad R (DevExpress) 07.12.2012

                                  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

                                • James Austin 07.12.2012

                                  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;
                                          }
                                  

                                • James Austin 07.13.2012

                                  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;
                                          }
                                  

                                • James Austin 07.16.2012

                                  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.

                                You must  log in  or  register  to leave comments
                                0

                                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.

                                • James Austin 12.06.2012

                                  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.

                                • James Austin 12.06.2012

                                  Just an extra comment on this, the DevExpress controls have been and are really useful.

                                You must  log in  or  register  to leave comments
                                You must  log in  or  register  to leave an answer

                                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.