Hi,

I have tried to arrange so that when I delete a name in the listview it should also delete the name in the textfile that the listview is reading from. When I delete in the listview the name that was below the deleted name now moves up a place in the listview and unfortunately gets the deleted names resources.

Here is the code for deleting from the listview:

void Delete()
       {
            try
            {
                if (listViewKunder.SelectedItems.Count > 0)
                {
                    listViewKunder.Items.Remove(listViewKunder.SelectedItems[0]);
                    lkunder.RemoveAt(listViewKunder.SelectedItems[0].Index);
                }
            }
            catch { }
        }

So what should is do when I want the textfile to also delete the same things that gets deleted when I delete something in the listview? and why is the information from the deleted name passing on to the next name in the list, what can be done so that that information really gets deleted and the names in the list keeps their own information?

I have added 3 pics of the form so you guys get an idea of how it looks. in the third picture i have selected the name Hugo but in the info boxes it still say "Bettan" as Bettan used to be in that place in the list.

You remove the SelectedItem from the list, so I assume selection moves to the next item in the list.
Copy the value from the list item into a string variable before removing it from the list. Use the string variable in the next method call.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.