BrasilianGuy
IS-IT--Management
With my code below I'm trying to accomplish:
1. Change the color of the button for checked and uncheked - Done
2. Save the value of the button into a xml file if button is clicked - Not working
3. delete the value from the xml file if button is uncheked - Not done
4. retrieve the value to repopulate the form everytime I open it! - Not done
steps 3 and 4 I can work on them latter but now I'm stuck on step number 2
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
{
if (checkBox1.BackColor == Color.Red)
checkBox1.BackColor = Color.White;
else
checkBox1.BackColor = Color.Red;
}
}
private void button2_Click(object sender, EventArgs e)
{
{
if (checkBox1.Checked)
{
XmlDocument docXML = new XmlDataDocument();
docXML.LoadXml("<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<Numbers><Number>14</Number></Numbers>");
docXML.Save("Employees.xml");
}
else
{
//user didn't check the box
}
}
}
isn't it supposed to create a file in the root called employees.xml??
1. Change the color of the button for checked and uncheked - Done
2. Save the value of the button into a xml file if button is clicked - Not working
3. delete the value from the xml file if button is uncheked - Not done
4. retrieve the value to repopulate the form everytime I open it! - Not done
steps 3 and 4 I can work on them latter but now I'm stuck on step number 2
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
{
if (checkBox1.BackColor == Color.Red)
checkBox1.BackColor = Color.White;
else
checkBox1.BackColor = Color.Red;
}
}
private void button2_Click(object sender, EventArgs e)
{
{
if (checkBox1.Checked)
{
XmlDocument docXML = new XmlDataDocument();
docXML.LoadXml("<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<Numbers><Number>14</Number></Numbers>");
docXML.Save("Employees.xml");
}
else
{
//user didn't check the box
}
}
}
isn't it supposed to create a file in the root called employees.xml??