Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clear a TreeView

Tags:

c#

wpf

treeview

I'm loading a TreeView from a list, and the user has a button to delete an item and it deletes it from the list no problem, but there is also a button to update the TreeView with the list after items have been deleted, I have no problem adding the new items to the TreeView but is there a way to clear all the items in the TreeView before I add new items, so I don't have duplicates in the TreeView? I have tried looking on other spots on the internet for the answer but cant find it, I've tried simple things like:

treeView1.Items.Clear();

but it doesn't work.

Sorry, I mentioned it on a comment, below that I'm pretty sure this line does in fact clear it, I am just not using it in the right place, thanks all for your answers.

like image 281
Beef Avatar asked Jun 22 '11 20:06

Beef


People also ask

How do I delete an item in Treeview?

The Treeview widget items can be edited and deleted by selecting the item using tree. selection() function. Once an item is selected, we can perform certain operations to delete or edit the item.

How do you edit Treeview?

The TreeView allows you to edit nodes by setting the allowEditing property to true. To directly edit the nodes in place, double click the TreeView node or select the node and press F2 key. When editing is completed by focus out or by pressing the Enter key, the modified node's text saves automatically.

How do I disable Treeview in Python?

The Treeview widget is used to display a list of items with more than one feature in the form of columns. By default, the listed items in a Treeview widget can be selected multiple times, however you can disable this feature by using selectmode="browse" in the Treeview widget constructor.

What is Treeview in tkinter?

Introduction to the Tkinter Treeview widgetA Treeview widget allows you to display data in both tabular and hierarchical structures. To create a Treeview widget, you use the ttk.Treeview class: tree = ttk.Treeview(container, **options) A Treeview widget holds a list of items. Each item has one or more columns.


1 Answers

To clear a treeview, you clear the nodes.

treeView1.Nodes.Clear();
like image 188
rifaco Avatar answered Oct 24 '22 18:10

rifaco