then go back into the code and add or change lines to accommodate the added or dropped controls.
Doing some searching, I managed to find a way to use linq to programmatically check the form for checkboxes and
to be able to report to me the label text and the state.
The problem comes in with my grasp of XDocument and XElement. Here is a code snippet:
private void btnSave_Click(object sender, EventArgs e)
{
ConfDoc = new XDocument(new XDeclaration("1.0","utf-8","yes"),new XElement("Settings"));
var checks = (from Control c in this.Controls
select c).OfType<CheckBox>();
foreach (var check in checks)
if (check.Checked == true)
{
textBox1.AppendText(check.Text.ToString() + "\r\n");
new XElement(check.Name, check.Text.ToString());
}
ConfDoc.Save(Application.StartupPath +
@"\Test.XML", SaveOptions.None);
}
As you can see, the use of the foreach changes the textbook explanation of the use of XDocument. Is there another approach to using this incredibly cool XML tool? :crying:


Sign In
Create Account

Back to top









