如何使用SDK知道是否选中了复选框 [英] How to know whether a checkbox is checked or not using SDK

查看:88
本文介绍了如何使用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 //checked

If 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆