Create treeview programmatically in c#

Could someone please help me with this
I know that I should insert a treeview from the toolbox in the design page in order to Create treeview.
Is there is a way i could do it programmatically in c#

Thanks in advance
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

Toms EdisonTechnical ManagerCommented:
suzan_Author Commented:
thanks TechTiger007 for your help
but I need to create the treeview in run time not dynamically

Anurag ThakurTechnical ManagerCommented:
tree view control once place can be created at run time - means the data can be added at run time
have a look at the following sample
OWASP: Avoiding Hacker Tricks

Learn to build secure applications from the mindset of the hacker and avoid being exploited.

suzan_Author Commented:
thanks ragi0017

I know that but I need to create other tree view
depends on the data that I have
Hi Suzan,

Are you looking for a way to simply add a new treeview control to your form?  If so, do something like this:
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");

Open in new window

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
Toms EdisonTechnical ManagerCommented:
Hi Suzan,
The sample that I pointed out from msdn is creating a treeview during runtime and adding it to the page.

When you meant "during runtime" I understood that you wanted to create a tree view control based on some data create nodes and add this control to the page. This is what is done in the code. Correct me if I am  wrong
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.