I have a form to manage student. When I add, the data appear on ListView and TreeView at the same time and the same data. Everything works perfectly.
But one proble about Delete button. I choose the line from the ListView and Delete it. The ListView delete the item perfectly. But I don't know how to delete the item on ListView and automatically delete the item on the TreeView.
Thanks for your helping !!!
Note: When you insert the data to ListView and TreeView. When you fill the information into the textbox. Remember after that choose class on TreeView and Click BUTTON ADD.
If the item has been added at the same place in both the TreeView and the ListView, then you can make a note of the index of the selected item in the ListView before you delete it.
You can then use that index to locate the corresponding node in the TreeView and delete that node.
Dim index As Integer
index = ListView1.SelectedIndices.Item(0)
I see your point.
Then a slight change might be in order. Try this:
Dim key As String
Dim arrUser As ListView.SelectedListViewItemCollection
arrUser = liststudentListView.SelectedItems
For Each item As ListViewItem In arrUser
key = item.Text
This should remove the treenode containing the exact same student code as the item in the listview.