954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

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

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
csharp_user
Newbie Poster
5 posts since Nov 2011
Reputation Points: 10
Solved Threads: 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.

LesF
Newbie Poster
9 posts since May 2009
Reputation Points: 10
Solved Threads: 1
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: