1.MainDataSource
获取表单的数据源
下面这段代码是检查filed1不为空,若为空,则提示(需添加引用,system.windows.forms)
2. this.NameSpaceManager
NameSpace: Microsoft.Office.InfoPath
XPathNavigator text1 = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:field1",this.NamespaceManager); if (string.IsNullOrEmpty(text1.Value)) { MessageBox.Show("This field Cannot be null !"); } XPathNavigator tex2 = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:field2", this.NamespaceManager); tex2.SetValue("I just get the value");