I'm making a program that catalogs the names of the people I add in a listbox and save all the content to a file when you close the program.
Each line of the file is for a person:
Tommy
Marco
James
Dylan
When the program starts, the file data is loaded and add the names to listbox.
All this works great, but now I'm having trouble making something else.
Each person on the list need a variable to indicate whether it has paid and I want to save this variable together with his name on the file.
For this, I have:
bool paid;
private void checkbox_Paid_CheckedChanged(object sender, EventArgs e)
{
paid = true;
}
I have only one checkbox, and it needs to differ from each person in the listbox, according to the selected in the event:
private void listDOF_SelectedIndexChanged(object sender, EventArgs e)
{
}
But I do not know how to write this bool in the file for each person, save to the file together with name and load it.
I've tried something like:
foreach(string purchasers in listDOF.Items)
{
arq.WriteLine(purchases, paid);
}
Obviously this do not worked, I do not know how to assign the bool for each one of the purchasers and write it in the file.
I'm using .NET 4.5 in a WFA.
Thanks all in advance, if I able to do this, I will give a big step toward the knowledge.