Tip - Auto Fit Columns For DevExpress XtraTreeList
[C#, .NET, DevExpress, Tips]
If you are using the DevExpress XtraTreeList to present data, you might run into the following situation:
Here we can see that many columns are not wide enough to accommodate their contents.
You would think calling the BestFitColumns() method of the grid would resolve this issue.
It does not.
You need to do two things:
- Set the AutoWidth property of the OptionsView to false.
- Call the
BestFitColumns()
method of theXtraTreeList
.
If we re-run this application, we should see the following:
Here we can see the following:
- All the columns have been resized to accommodate their contents
- A scrollbar has been added so as to be able to navigate to the columns not visible in the current view.
TLDR
To auto-fit the contents of XtraTreeList
columns, set the AutoWidth
in the OptionsView
to false and then call BestFitColumns()
Happy hacking!