?
Solved

Create treeview programmatically in c#

Posted on 2008-11-15
6
Medium Priority
?
2,945 Views
Last Modified: 2013-12-17
Hi
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
suzan
0
Comment
Question by:suzan_
6 Comments
 
LVL 13

Expert Comment

by:TechTiger007
ID: 22969986
0
 

Author Comment

by:suzan_
ID: 22971982
thanks TechTiger007 for your help
but I need to create the treeview in run time not dynamically

suzan
0
 
LVL 26

Expert Comment

by:Anurag Thakur
ID: 22973331
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
http://www.c-sharpcorner.com/UploadFile/scottlysle/TreeviewBasics04152007195731PM/TreeviewBasics.aspx
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:suzan_
ID: 22973417
thanks ragi0017

I know that but I need to create other tree view
depends on the data that I have
0
 
LVL 3

Accepted Solution

by:
torrie01 earned 2000 total points
ID: 22978673
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);
this.Controls.Add(myTreeView);
 
//now that it's on the form, you can add nodes to it
myTreeView.Nodes.Add(new TreeNode("something");

Open in new window

0
 
LVL 13

Expert Comment

by:TechTiger007
ID: 22985939
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
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses
Course of the Month14 days, 17 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question