I have a listbox titled lstResult1 and lstResult2. I am pretty new to C# programming. I am trying to save the two list boxes along with the rest of the file. I was able to save the three textboxes to the file but i cant get the two listboxes to save to the file. lstResult1 contains names (string) and lstResult2 contains (double) values. Any help would be appreciated
Here is my code. i dont know why but im trying to do the second listbox first. but i do need help with both.
private void mnuFileSave_Click(object sender, EventArgs e)
private void mnuFileSave_Click(object sender, EventArgs e)
{
if (dlgSave.ShowDialog() == DialogResult.OK)
{
FileStream fileAndorHunsFormulaWorksheet = new FileStream(dlgSave.FileName, FileMode.Create, FileAccess.Write, FileShare.Write);
BinaryWriter bnrAndorHunsFormulaWorksheet = new BinaryWriter(fileAndorHunsFormulaWorksheet);
bnrAndorHunsFormulaWorksheet.Write(txtFormulaName.Text);
bnrAndorHunsFormulaWorksheet.Write(txtFormulaNumber.Text);
bnrAndorHunsFormulaWorksheet.Write(txtItemName.Text);
foreach (double value in lstResult2.Items)
{
bnrAndorHunsFormulaWorksheet.Write(Convert.ToString(lstResult2.Items));
bnrAndorHunsFormulaWorksheet.Flush();
}
bnrAndorHunsFormulaWorksheet.Close();
fileAndorHunsFormulaWorksheet.Close();