Saving and Deleting in Listview

sarim123

Member
Licensed User
Longtime User
:sign0104: Hello Everyone, two questions,
#1. I was wondering if there was some kind of generic/simple code that would save data from a ListView. Something that would save the data if the app is closed. I was thinking that a text file would do the trick but could someone direct me on ways to do that

#2. How do you delete an object from a ListView. I have some sample code that i am experimenting with. I have attached it below.

Thanks in advance to everyone who helps!
 

Attachments

  • editext3.zip
    6.8 KB · Views: 315

tremara1

Active Member
Licensed User
Longtime User
list item remove

I think that the listView.RemoveAt(index) removes item.....hope this helps
 
Upvote 0

sarim123

Member
Licensed User
Longtime User
Can someone please help?!?!?!?! It doesnt work! Thanks for helping everyone!
 

Attachments

  • editext3.zip
    6.7 KB · Views: 227
Upvote 0

JonPM

Well-Known Member
Licensed User
Longtime User
There are several errors, but here it is in working order. When you create a button click event, make sure you do it right otherwise it won't work. Your btnDelete event wasn't typed correctly. Look at this simple project and let us know if you have questions.
 

Attachments

  • tst.zip
    6.8 KB · Views: 278
Upvote 0

sarim123

Member
Licensed User
Longtime User
Thanks so much JonPM!!!!!!!! But 2 issues. The thing that i really wanted to do is delete it from the text file. Right now if i close the app, the previously deleted listview items reappear. Another issue is that how would i make it so it would it would ask to delete before it deletes it. Thanks for all your continuous support!
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Here you are.
JonPM unfortunately moved the File.WriteList(... line from Activity_Pause into the btnSubmit_Click routine. But in that case when deleting an entry the file was not updated.
I moved it back into Activity_Pause.
As long as the Activity is alive no need to update the file all data are stored in the list. Only when the Activity is paused the file is updated.
Added a message box before deleting an entry.
The delete button is only visible when an entry has been selected.
Set the edtText ForceDone property to True (in the Designer). When you click on the OK button on the keyboard this one is hidden.

Best regards.
 

Attachments

  • editext4.zip
    7 KB · Views: 333
Upvote 0

sarim123

Member
Licensed User
Longtime User
Thanks so much Everyone, your amazing! But one last thing, how would you make a listview transparent. I tried putting ltvTexts.ScrollingBackgroundColor = Colors.Transparent into the Activity_Create but that didnt work.How would i do that? Thanks for helpin guys!
 
Last edited:
Upvote 0
Top