infopath 用c#获得重复表(repeat table)数据---急啊!在线等!--多谢!
我按照网上的例子做了一个表单:
我只在infopath的form中拖入了一个“重复表:my:group24”(ViewContext:Ctrl36),该重复表中拖入了一个“textbox”(ViewContext:Ctrl37)
代码如下:
using Microsoft.Office.InfoPath;
using System;
using System.Windows.Forms;
using System.Xml;
using System.Xml.XPath;
using mshtml;
using System.Runtime.InteropServices;
namespace 模板1
{
public partial class FormCode
{
public void InternalStartup()
{
EventManager.FormEvents.Submit += new SubmitEventHandler(FormEvents_Submit);
}
public void FormEvents_Submit(object sender, SubmitEventArgs e)
{
XPathNavigator xn = this.MainDataSource.CreateNavigator();
XPathNavigator xProductOfType1 = xn.SelectSingleNode("/my:myFields/my:group23/my:group24[1]", this.NamespaceManager);
CurrentView.SelectNodes(xProductOfType1, xProductOfType1, "CTRL36");
XPathNodeIterator contextNodes = CurrentView.GetContextNodes(xProductOfType1, "CTRL36");
foreach (XPathNavigator contextNode in contextNodes)
{
MessageBox.Show(contextNode.Name);
MessageBox.Show(contextNode.InnerXml);
MessageBox.Show(contextNode.Value);
}
e.CancelableArgs.Cancel = false;
}
}
}
测试时我通过插入行输入了3行数据(1、2、3),调试结果:循环第一次正常显示textbox中的数据,第二次本应该显示第二行的数据,可结果直接显示了重复表(my:group24)所有的数据。
急啊,都弄了好几天了,请帮忙!!!多谢!