How to remove a selected item in a treeview C #

0

I am developing a new application but I have a final problem to solve and I tried googlear and nothing I can not find any examples.

In fact I want to delete the item in the treeview that has been sealed

I tried this way but gave me a mistake

  

Error 1 'System.Windows.Forms.TreeView' does not contain a definition for 'Items' and no extension method 'Items' accepting a first argument of type 'System.Windows.Forms.TreeView' could be found (are you missing a using directive or an assembly reference?)

I tried this way:

listMessages.Items.Remove(listMessages.SelectedItem);
    
asked by anonymous 21.07.2017 / 21:48

1 answer

1

There are no Items and SelectedItem properties in a Windows Forms tree view .

You need to use Nodes instead of Items and SelectedNode instead of SelectedItem .

See the official documentation for the control.

listMessages.Nodes.Remove(listMessages.SelectedNode);
    
21.07.2017 / 21:50