i am created the view at run time using the following code

TreeView myTreeView = new TreeView();
myTreeView.Location = new Point(0,0);
myTreeView.Size = new Size(100,200);

//now that it's on the form, you can add nodes to it
myTreeView.Nodes.Add(new TreeNode("something");

but runtime the tree view not displayed in the form. any other thing is need. please give ur suggestions.........


Karthikeyan S

it appeared on my form when I pasted that into a button and then ran it and clicked it.


Make new project
drop a button on the form
double click on it
paste in the code you posted

That is all I did.
If yours isnt working, Id suggest your code isnt running - try debugging it.

hi thank u

actualy i am using that code inside the splitcontainer. so i am not able to view at runtime.(its my mistake)

instead of using


i am using


then it shows the treeview on the form.

Thank You.

if there is possible to create more than one treeview at run time?

i am using the one function createtreeview()

if i use recursively. the new treeview must be create.

but i do't know how is it possible.

if possible please send the details..

This article has been dead for over six months. Start a new discussion instead.