简体   繁体   English

在代码中将事件添加到InfoPath的下拉列表框中

[英]Adding event in code to Drop-down list box in InfoPath

I'm trying to add the OnChange or Changed or IndexChanged event to the "Drop-down list box" control in InfoPath using VS Tools for applications. 我正在尝试使用VS Tools为应用程序将OnChange或Changed或IndexChanged事件添加到InfoPath中的“下拉列表框”控件中。

If found the following code how this is done with buttons: 如果找到以下代码,如何通过按钮完成操作:

((ButtonEvent)EventManager.ControlEvents["ButtonName"]).Clicked += new ClickedEventHandler(FormCode_Clicked);

I would think this is also possible with other controls, but I can't seem to find the cast object to be able to add the event to my drop-down list. 我认为其他控件也可以做到这一点,但是我似乎找不到能够将事件添加到下拉列表中的强制转换对象。

((?)EventManager.ControlEvents["Project_x0020_Number"]).SelectedIndexChanged += new EventHandler(FormCode_SelectedIndexChanged);

I tried the object ComboBox, but then their was an error that this object could not be casted to the type ComboBox. 我尝试了对象ComboBox,但随后出现一个错误,即无法将此对象转换为ComboBox类型。

I hope someone can give me some advice. 我希望有人能给我一些建议。 All I want to do is basically run a Query that filters my data depending on the selected value in my "Project Number" box. 我要做的基本上是运行一个查询,该查询根据“项目编号”框中​​的选定值过滤数据。

maybe also good to mention: I'm changing the form that will go in a word document (used as template in SharePoint). 也许还值得一提:我正在更改Word文档(在SharePoint中用作模板)中使用的表单。 I don't really think this matters, but thought I mention it any way. 我并不认为这很重要,但我想我会以任何方式提及。

Thanks in advance 提前致谢

Oxillery Oxillery

You can approach this problem without writing code. 您无需编写代码即可解决此问题。 I dont have Infopath in this machine to give you a sample. 我在这台机器上没有Infopath可以提供样品。 But I think you can solve this with the method described here in point 26: 但是我认为您可以使用第26点介绍的方法解决此问题:

http://www.bizsupportonline.net/infopath2003/avg-function-infopath.htm http://www.bizsupportonline.net/infopath2003/avg-function-infopath.htm

Instead of calculating the average as in the example above you will set some parameters in your datasource and perform a refresh based on the value set in your dropdown. 您无需在上面的示例中计算平均值,而是在数据源中设置一些参数,然后根据下拉列表中设置的值执行刷新。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM