如何使用SDK知道是否选中了复选框 [英] How to know whether a checkbox is checked or not using SDK
问题描述
作为标题。我可以获取复选框控件及其名称,但无法在任何地方找到该值。
您好,
如果您插入表单控件,我们可以使用以下代码来检查或取消选中控件。
使用W14 = DocumentFormat.OpenXml.Office2010.Word;
W14.SdtContentCheckBox sdtContentCheckBox1 = sdtProperties1.GetFirstChild< W14.SdtContentCheckBox>();
W14.Checked checked1 = sdtContentCheckBox1.GetFirstChild< W14.Checked>();
checked1.Val = W14.OnOffValues.Zero; //未选中
// checked1.Val = W14.OnOffValues.One //已选中如果您要插入ActiveX复选框,很遗憾,  ;我们无法获得它的价值。
我建议您下载Open XML SDK Tool来比较文件并生成代码。
你可以找到如果是表单控件,则有value属性:
如果它是ActiveX控件,在检查或取消选中后,控件将更改为其他形状。
问候,
Celeste
As title. I can get the checkbox control and its name but can't find the value anywhere.
Hello,
If you insert a form control, we could use the folowing code to check or unchecked the control.
using W14 = DocumentFormat.OpenXml.Office2010.Word; W14.SdtContentCheckBox sdtContentCheckBox1=sdtProperties1.GetFirstChild<W14.SdtContentCheckBox>(); W14.Checked checked1=sdtContentCheckBox1.GetFirstChild<W14.Checked>(); checked1.Val = W14.OnOffValues.Zero; //unchecked // checked1.Val =W14.OnOffValues.One //checkedIf you are inserting an ActiveX checkbox, unfortunately, we are unable to get its value.
I would suggest you download Open XML SDK Tool to compare files and generate code.
You could find if it is a form control, there is value property:
If it is an ActiveX conrtol, after checking or unchecking, the control is changed into a different shape.
Regards,
Celeste
这篇关于如何使用SDK知道是否选中了复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!