i have 3 check boxes Nuts Cherries Sprinkles
also i am using Streamwriter and StreamReader
i also have 2 combo boxes and im using an index for those to work with writer/reader
but my checkboxes wont work i am using if ele if statments for the check boxes and im out of ideas syntax is correct as far as i know (if theres another way to get my check boxes to read and write let me know) THERE HAS TO BE A DIFFRENT WAY syntax wise to make this work lets PLEASE LET ME KNOW
for some reason i get no errors in the Debugger
THIS IS my LOAD BUTTON //(THIS IS WHERE IM HAVING PROBLEMS)
private void openToolStripMenuItem_Click(object sender, EventArgs e)
{
StreamReader sr;
string strInput;
OpenFileDialog ofd = new OpenFileDialog();
if (ofd.ShowDialog() == DialogResult.OK)
{
sr = new StreamReader(ofd.FileName);
strInput = sr.ReadLine();
savedIndex = Convert.ToInt32(strInput);
flavorBox.SelectedIndex = savedIndex;
syrupBox.SelectedIndex = savedIndex;
if (Nuts.Checked == true)
{
sr.ReadLine();
}
else if(Cherries.Checked == true)
{
sr.ReadLine();
}
if(Sprinkles.Checked == true)
{
sr.ReadLine();
}
sr.Close();
}
}
THIS IS MY SAVE BUTTON (AND HERE TO I MUST BE MISSING SOMETHING)
public partial class Form1 : Form
{
int savedIndex = 0;
public Form1()
{
//index for flavor of icecream
InitializeComponent();
flavorBox.SelectedIndex = 0;
syrupBox.SelectedIndex = 0;
pictureBox1.Image = Properties.Resources.Vanilla;
//Nuts.
}
// my save fucntion
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
{
StreamWriter sw;
SaveFileDialog sfd = new SaveFileDialog();
if (sfd.ShowDialog() == DialogResult.OK)
{
sw = new StreamWriter(sfd.FileName);
savedIndex = flavorBox.SelectedIndex;
sw.WriteLine(flavorBox.SelectedIndex);
if (Nuts.Checked == true)
{
sw.WriteLine();
}
else if (Cherries.Checked == true)
{
sw.WriteLine();
}
else if(Sprinkles.Checked == true)
{
sw.WriteLine();
}
sw.Close();
}
}
THIS IS MY REVERT BUTTON WHERE THE USER CAN OPEN A SAVED FILE THEN MAKE CHANGES AND JUST CLICK REVERT AND IT WILL GO BACK TO ITS ORIGINAL SAVED FILE WITH OUT RE OPENING THE FILE
private void revertToolStripMenuItem_Click(object sender, EventArgs e)
{
flavorBox.SelectedIndex = savedIndex;
syrupBox.SelectedIndex = savedIndex;
}
THIS IS MY INDEX FOR THE COMBO BOX
private void flavorBox_SelectedIndexChanged(object sender, EventArgs e)
{
int index = flavorBox.SelectedIndex;
if (index == 0)
{
pictureBox1.Image = Properties.Resources.Vanilla;
}
else if (index == 1)
{
pictureBox1.Image = Properties.Resources.Chocolate;
}
else if (index == 2)
{
pictureBox1.Image = Properties.Resources.strawberry;
}
}
HERES MY EXPEREMENTAL IDEA TRYING TO GET THE CHECK BOX TO WORK
private void Nuts_CheckedChanged(object sender, EventArgs e)
{
if(Nuts.Checked == true)
{
Nuts.Checked = true;
}
else if(Nuts.Checked != true)
{
//Nuts.unchecked()
}
Aucun commentaire:
Enregistrer un commentaire