So I have a document that I am editing through a WPF(C#) application. I have successfully edited Plain Text content controls, but now I am stuck checking/unchecking the Checkboxes within the form.
I successfully find the checkbox and set the value and save the document, but the checkboxes that are set to true are never checked within the word document when I open it.
Here is the code that I use to manipulate the checkboxes. NOTE: I access the checkboxes at the tag level, hence the field.parent.parent
private static void SetCheckBox(OpenXmlElement field, bool isChecked)
{
var checkBox = field.Parent.Parent.Descendants<SdtContentCheckBox>().ToList();
foreach (var check in checkBox)
{
if (isChecked)
{
check.Checked.Val = OnOffValues.True;
}
else
{
check.Checked.Val = OnOffValues.False;
}
MessageBox.Show(check.Checked.Val);
}
}
When I display the values in the MessageBox they display 0/1 for true/false. So they are in fact being set.
Am I doing this properly?