Hi there,
In my program i have given the user the possibillity to add new buttons to the form I then serialize the form to a xml file so it is saved. Any data that is edited while the program is running will be saved (for example user edits the buttons text) for next time the program runs, and it does successfully.
However when they add a new button, it get serialized to the xml file but when i run the program again and read from the xml file, that new button does not exist.
Code for serializing the forms data to the xml, saving any info about the buttons.
if (roomCtrl is Button)
{
xmlSerialisedForm.WriteElementString("Text", ((Button)roomCtrl).Text);
xmlSerialisedForm.WriteElementString("Backcolor", ((Button)roomCtrl).BackColor.ToString());
xmlSerialisedForm.WriteElementString("X", ((Button)roomCtrl).Location.X.ToString());
xmlSerialisedForm.WriteElementString("Y", ((Button)roomCtrl).Location.Y.ToString());
}
code for deserialing from the xml.
case "System.Windows.Forms.Button":
((System.Windows.Forms.Button)ctrlToSet).Name = controlName;
((System.Windows.Forms.Button)ctrlToSet).Text = n["Text"].InnerText;
((System.Windows.Forms.Button)ctrlToSet).Location = new System.Drawing.Point(Convert.ToInt32(n["X"].InnerText), Convert.ToInt32(n["Y"].InnerText));
if (n["Backcolor"].InnerText == "Color [LawnGreen]")
{
((System.Windows.Forms.Button)ctrlToSet).BackColor = System.Drawing.Color.LawnGreen;
}
else if (n["Backcolor"].InnerText == "Color [Tomato]")
{
((System.Windows.Forms.Button)ctrlToSet).BackColor = System.Drawing.Color.Tomato;
}
break;
Any ideas on what it might be or if i am just missing something??
Thanks in advanced.
LNC