1.11M Members

Deleting name in listview should result in deleting the same name in the textfile

 
0
 

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.

Attachments 1.jpg 42.35KB 2.jpg 44.62KB 3.jpg 43.94KB
 
0
 

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.

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: