I am having issues figuring out what this issue is. I have googled around and have not found many solutions to this issue. The only “solution” I found was a hack to expand then collapse the last node.
this.Nodes[this.Nodes.Count - 1].Expand();
this.Nodes[this.Nodes.Count - 1].Collapse();
As you can see from this screen shot the last node is partially cut off and the only way to expose it is to expand the node which will cause the TreeView to re-render itself correctly.

I am pragmatically adding nodes to the TreeView. I do not know if this affects the outcome, but I have extended the TreeView to my own class so I can add a few properties and methods to it.
public class MyTreeView : TreeView
{
public void BuildTree()
{
this.Nodes.Clear();
foreach (TestSetFolder folder in Folders)
{
MyTreeNode node = new MyTreeNode();
node.Name = folder.Name;
node.Text = folder.Name;
node.Tag = folder;
node.FolderID = folder.NodeID;
node.IsPopulated = false;
this.Nodes.Add(node);
}
}
}
This is how I am adding the nodes to the list. Does anyone have a clean solution to this issue?
Use
treeView.BeginUpdate()andtreeView.EndUpdate()before and after any visual changes.SuspendLayout() and ResumeLayout() also can be useful!
If you want UI update, do not add all nodes in one go! add one by one, sandwiched between begin and endupdate calls.