Search code examples
treeview

Treeview not displaying in Windows form .net 4.8


We have a legacy Windows application from .net framework 3.5 and we are upgrading it to .net framework 4.8. One issue we are facing is we have a treeview where its data is automatically filled up and displayed when the form is first loaded in form_load() event. However when upgrading to .net 4.8 it does not show up automatically until we do loading it again.

Nothing has been changed in the code as below

treeView1.BeginUpdate();

treeView1.Nodes.Add()...

treeView1.EndUpdate()

I have tried several below ways but still not working:

  • select a node by treeView1.SelectedNode after EndUpdate()
  • Invalidate()
  • Refresh()
  • Update()

The weird thing is if we do it exactly the same via a button click after form loaded then it worked.

Any helps? Thanks, Kelvin


Solution

  • FYI I have put the tree data loading into form Shown event and it works.