在InfoPath 2007中更改事件后编辑组合框 [英] Progamming a Combo Box After Change Event in InfoPath 2007
问题描述
我正在尝试对一个组合框进行编程,以便在 中设置文本字段的值。 Infopath中的3列重复表
第1列..............第2列............... ........第3栏
ICDMCode(组合框)................. ICDMdescr ............... 自由文本
辅助数据源是"tblICDMCodes"
1。 cboBox绑定到field = strICDMcode; xpath = / my:myFields / my:Exam / my:grpICDM / my:grpICDMCodes / my:cboICDMCode
2。文本字段是xpath = / my:myFields / my:Exam / my:grpICDM / my:grpICDMCodes / my:fldICDM_Text
用户从第1列的组合框中选择ICDMCode后表格我希望第(2)栏填充文字说明,这是tblICDMCodes中的第二个字段:
所以这是代码:
Public Sub cboICDMCode_Changed(ByVal sender As Object,ByVal e As XmlEventArgs)
   '在此处编写代码以更改主要数据来源。
'/ my:myFields / my:Exam / my:grpICDM / my:grpICDMCodes / my:cboICDMCode
; '为数据源创建一个导航器
暗淡ICDMdata作为的XPathNavigator = Me.DataSources(QUOT; tblDiagCode")CreateNavigator
            '创建一个位于当前站点的xpnavigator对象;这是cboICDMcod
Dim ICDMcode As XPathNavigator = e.Site.CreateNavigator
ICDMcode.MoveToParent()
暗淡ICDMdescr作为字符串= ICDMdata.SelectSingleNode(QUOT; / ICDMdata / [strDiagCode = '"&安培; e.Site.InnerXml&安培;"'] / strDiagDescr" ;, Me.NamespaceManager).InnerXml
ICDMcode.SelectSingleNode(QUOT; /我的:myFields /我的:检查/我的:grpICDM /我的:grpICDMCodes /我的:fldICDM_Text" ;, Me.NamespaceManager).SetValue(ICDMdescr)
  &NBSP ;    结束次级
提前感谢您的任何帮助。
jawsurgeon
嗨Jawsurgeon,
你所获得的代码基本上是正确的。  您需要进行的一项更改是在
中使用相对XPath’&ndquo; SelectSingleNode”来电群组。您已经有一个指向组合框字段的XPathNavigator对象,如下所示:
Dim ICDMcode As XPathNavigator = e.Site.CreateNavigator
因此,当您要在与该组合框相同的行上设置文本框的值时,请使用一个相对XPath,将一个级别
升级到父行的节点,然后返回到同一行的文本框字段。
< p style ="margin:0in 0in 0pt"> ICDMcode.SelectSingleNode(" ../ my:ICDMdescr",Me.NamespaceManager)。SetValue(ICDMtxt)
这应该可以解决问题。
I am trying to program a combo box to set the value of a text field in a 3 column repeating table in Infopath
column 1..............column 2.......................column 3
ICDMCode (combo box)................. ICDMdescr ............... free text
The secondary data source is "tblICDMCodes"
1. The cboBox is bound to field = strICDMcode ; xpath = /my:myFields/my:Exam/my:grpICDM/my:grpICDMCodes/my:cboICDMCode
2. the text field is xpath = /my:myFields/my:Exam/my:grpICDM/my:grpICDMCodes/my:fldICDM_Text
After the user selects an ICDMCode from the combo box in column1 of the table I want column(2) populated with the text description which is the 2nd field in the tblICDMCodes:
So here is the code:
Public Sub cboICDMCode_Changed(ByVal sender As Object, ByVal e As XmlEventArgs)' Write your code here to change the main data source.
'/my:myFields/my:Exam/my:grpICDM/my:grpICDMCodes/my:cboICDMCode
'create a navigator to the datasource
Dim ICDMdata As XPathNavigator = Me.DataSources("tblDiagCode").CreateNavigator
'create an xpnavigator object positioned onthe current site; which is the cboICDMcod
Dim ICDMcode As XPathNavigator = e.Site.CreateNavigator
ICDMcode.MoveToParent()
Dim ICDMdescr As String = ICDMdata.SelectSingleNode("/ICDMdata/[strDiagCode = '" & e.Site.InnerXml & "']/strDiagDescr", Me.NamespaceManager).InnerXml
ICDMcode.SelectSingleNode("/my:myFields/my:Exam/my:grpICDM/my:grpICDMCodes/my:fldICDM_Text", Me.NamespaceManager).SetValue(ICDMdescr)
End Sub
Thanks in advance for any help.
jawsurgeon
Hi Jawsurgeon,
The code you’ve got there is basically right. The one change you need to make is to use relative XPath’s in your “SelectSingleNode” calls. You’ve already got an XPathNavigator object pointing to the combo box field like this:
Dim ICDMcode As XPathNavigator = e.Site.CreateNavigator
So, when you want to set the value of the text box on the same row as that combo box, use a relative XPath to step up one level to the parent row’s node, and then back down to the textbox field on the same row.
ICDMcode.SelectSingleNode("../my:ICDMdescr", Me.NamespaceManager).SetValue(ICDMtxt)
That should fix the problem.
这篇关于在InfoPath 2007中更改事件后编辑组合框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!