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