Hi,
I am having some trouble with setting the column widths in an outlook style treeview control. I would like the column to autoadjust based upon the visible nodes (mainly the longest nodes), but the AutoSizeMode works in conjunction with the PreferredCellSize property, which is obviously unknown due to the nested depths of the tree. I have tried firing up and down the UIElement hierarchy of the node after expansion in order to do this manually, but the UIElements of my childnodes are null. Here's what I want it to do:
+ Node 1 (10) + Node 2 (1000) + Child 1 (4)and after expanding Child 1 to...+ Node 1 (10) + Node 2 (1000) + Child 1 (4) - Sub child item (1)
And then back again... For the time being, we've been using PerformAutoResize with AllNodesWithDescendants, as it's the only one which allocates enough width as to not truncate the first columns node text.
Is this at all possible?
Thanks, Tom (p.s. this is the last push before release, just tidying things up!)
I am not sure I followed this, but it is possible you just need to call PerformAutoResize(VisibleNodes) in response to the BeforeExpand and BeforeCollapse events.
Haha I can't beleive I didn't try that, I've spent the last 45 minutes trying everything else! That worked perfectly, thanks a million.
Also I think the problem I was having is I was filling the tree, THEN calling the PerformAutoResize, then expanding the node (so the node wasn't expanded when the resizing was happening...). Rookie mistake but it's all sorted now.
These "finishing touches" really make the application much nicer.
Thanks, Tom
Can you share the code with us, We also want to increase the width of the column of treeview
I just call:
tree.ColumnSettings.RootColumnSet.Columns(0).PerformAutoResize( _ UltraWinTree.ColumnAutoSizeMode.VisibleNodes)
tree.ColumnSettings.RootColumnSet.Columns(1).PerformAutoResize( _ UltraWinTree.ColumnAutoSizeMode.VisibleNodes)
From the BeforeExpand, AfterExpand and AfterCollapse events on the tree. It's also called whenever our node counting code is finished (basically whenever the text on the tree changes)
Hope this helps, Tom
Hello Tom,
Thanks for the quick reply, but unfortunately the code didnt work for us. Please find below the code we are using. In our tree view we have 3 levels, for all the 3 levels we want to extend the column to the end so that it would look like a single row :
Private sub LoadTreeView ulTreeviewItems.DataSource = dsItem.Tables(0)
ulTreeviewItems.ViewStyle = Infragistics.Win.UltraWinTree.ViewStyle.Grid ulTreeviewItems.NodeLevelOverrides(0).BorderStyleNode = Infragistics.Win.UIElementBorderStyle.None ulTreeviewItems.NodeLevelOverrides(0).ShowColumns = Infragistics.Win.DefaultableBoolean.False ulTreeviewItems.NodeLevelOverrides(1).BorderStyleNode = Infragistics.Win.UIElementBorderStyle.None ulTreeviewItems.NodeLevelOverrides(1).ShowColumns = Infragistics.Win.DefaultableBoolean.False
If ulTreeviewItems.NodeLevelOverrides(2).ColumnSet Is Nothing Then If ulTreeviewItems.ColumnSettings.ColumnSets.Exists("myColumnSet") = False Then columnSetItem = ulTreeviewItems.ColumnSettings.ColumnSets.Add("myColumnSet") End If End If ulTreeviewItems.NodeLevelOverrides(2).ColumnSet = columnSetItem ulTreeviewItems.NodeLevelOverrides(2).ColumnSet.ColumnSettings.AutoFitColumns = Infragistics.Win.UltraWinTree.AutoFitColumns.None ulTreeviewItems.NodeLevelOverrides(2).ColumnSet.ColumnSettings.BorderStyleCell = Infragistics.Win.UIElementBorderStyle.RaisedSoft
For i As Integer = 1 To ulTreeviewItems.NodeLevelOverrides(2).ColumnSet.Columns.Count - 1 ulTreeviewItems.NodeLevelOverrides(2).ColumnSet.Columns(i).Visible = False Next
ulTreeviewItems.NodeLevelOverrides(0).NodeAppearance.Image = imgTreeView.Images(0) ulTreeviewItems.NodeLevelOverrides(1).NodeAppearance.Image = imgTreeView.Images(0) ulTreeviewItems.NodeLevelOverrides(2).NodeAppearance.Image = imgTreeView.Images(1) ulTreeviewItems.NodeLevelOverrides(2).ShowExpansionIndicator = Infragistics.Win.UltraWinTree.ShowExpansionIndicator.Never ulTreeviewItems.Override.NodeSpacingAfter = 3
If ulTreeviewItems.Nodes.Count <> 0 Then ulTreeviewItems.Nodes(0).Override.NodeSpacingBefore = 5 ulTreeviewItems.ExpansionIndicatorPadding = 10 End If
End Sub
In BeforeExpand, AfterExpand and AfterCollapse events we used the code which you gave, but without any luck. Can you please guide us where we are going wrong. Also please find attached the screen shot for the tree view.