Need help saving data from checkedlistbox
I'm working on a checklist project to keep track of which songs from which albums I've edited and I'm having trouble figuring out how to save both the checked states and list text as a beginner. The method I was trying was to create individual text files for each album but I'm not sure how to write and read the true/false statements for a checked box in the same line as the text and need some help getting pointed in the right direction for this

11 Replies
What's the UI framework you're using?
Oh I forgot to clarify, I'm using .NET
What UI framework
Winforms, WPF, Avalonia, MAUI, WinUI, Uno...
Ah sorry, Winforms
I think you need a
BindingList<T>: https://learn.microsoft.com/en-us/dotnet/api/system.componentmodel.bindinglist-1?view=net-9.0
Though I haven't dabbled in Winforms much, so maybe there are better waysI have an idea for this, asked ChatGPT 🙂
If you save like this,
To read the data:
To write it back:
This way:
Each line includes both the song text and its checked state,
It’s easy to split with Split('|'),
You can easily use LINQ for filtering or updating (Where, Select, FirstOrDefault, etc.).
It’s simple, clean, and scalable — later they could even add more fields like AlbumName or Duration without changing the structure.
I'll check this out, thank you!
Ahh I see, this makes sense I didn't realize it was so simply to split text using Split() thank you that's helpful!
Or you could just use JSON instead of rolling your own format
That's true I did saw a post about using json on vb. I don't know anything about json files right now but they sound useful
Oh that looks much cleaner, I'll do some research to understand this better
Could even just store everything in one file instead of having each album be a separate one
Ideally, you'd want to use a database
But baby steps, JSON is good enough
Yeah I'd definitely want to do this eventually. My plan with this project was to start with some simpler potentially clunky stuff and then slowly make it more efficient and add in more functions like a media player