Treeview refresh programmatically+vb.net 2005 windows programming

Hi,
When I add a new folder to windows explorer programmatically I expect the treeview represnting the explorer to refresh as well.Any suggestions on how after adding a folder refresh the treeview

Cheers
RIASAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

klakkasCommented:
You should place a timer in your form and check periodically for folder changes.

When you determine that a change has happened, then update the TreeView.
RIASAuthor Commented:
Hi,
Thanks for your reply.The folder is added programmatically so I need to refresh the treeview as son as the folder is added.
How to refresh the treeview any suggestions?
klakkasCommented:
Since you are creating programmatically the new folder, then you know exactly when and where to add the new node.

Assuming that you have built the treeview, then you know how to navigate in the nodes and find the folder that the new folder was created in. So, if you create a new folder in c:\Temp named Myfolder, you should do this:

dim nd as TreeNode = TreeView1.Nodes.Find([The Name of the c:\Temp Node], true)
nd.nodes.add ("myForlder")

The only thing to watch here is to set the name of each node when you create them, in a way that you will be able to find them later.
Starting with Angular 5

Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.

RIASAuthor Commented:
Hi,
I get this error
Error 13 Value of type '1-dimensional array of System.Windows.Forms.TreeNode' cannot be converted to 'System.Windows.Forms.TreeNode'.
klakkasCommented:
Sorry, my fault.

TreeView1.Nodes.Find returns an array, so we want to get the first item.
So replace:
dim nd as TreeNode = TreeView1.Nodes.Find([The Name of the c:\Temp Node], true)
With:
dim nd as TreeNode = TreeView1.Nodes.Find([The Name of the c:\Temp Node], true)(0)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RIASAuthor Commented:
Cheers mate will try and be back
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.