Click here to Skip to main content
16,017,755 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I want to ask you How to Delete nodes from Tree view Control in C# only
Posted
Comments
Sergey Alexandrovich Kryukov 11-Apr-11 2:58am    
Oh, not again!
Tag it! WPF, WinForms, ASP.NET, what?!!
--SA
OriginalGriff 11-Apr-11 3:02am    
Change your user ID: Never post your email address in any forum, unless you really like spam! If anyone replies to you, you will receive an email to let you know

Assuming you want to work with System.Windows.Forms.TreeView, use System.Windows.Forms.TreeView.Nodes property; it has the methods you need.

—SA
 
Share this answer
 
Comments
Michel [mjbohn] 11-Apr-11 3:09am    
That's the way I'd answered if my caffeine level wasn't that low ;)
my 5
Sergey Alexandrovich Kryukov 11-Apr-11 3:55am    
Thank you. Caffeine is not needed for work. It does not hurt much though, in my opinion. I'm more under tannin, but not concerned about it.
--SA
Google is your friend: Be nice and visit him often. He can answer questions a lot more quickly than posting them here...

If you had searched using your subject, you would have found the answer on MSDN[^]
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 11-Apr-11 3:52am    
The OP who do not indicate which UI library is used usually cannot use Google.
They do the search and see 3-4 or more different Tree Views. Which one to look at? :-)
Nevertheless, you're right. My 5.
--SA
Delete selected node
treeView1.SelectedNode.Remove();


via index
treeView1.Nodes[0].Remove();
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 11-Apr-11 2:57am    
Why selected? Basically, correct, but you need to indicate, for what library? (And OP should tag it!)
Please see my Answer.
--SA
Michel [mjbohn] 11-Apr-11 3:02am    
But OP has tagged C#. And because the question wasn't that detailed I showed both selected and index
[EDIT] You surely meant ASP,WPF etc to be tagged. Need more caffeine to awaken :)
Sergey Alexandrovich Kryukov 11-Apr-11 3:48am    
No, C# is not enough. For example, in WPF the answer would be different.
--SA
Sergey Alexandrovich Kryukov 11-Apr-11 3:50am    
I've written what I meant. See also my comment to the Question, it is correct.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900