DataDOMEvent.NewValue 属性
命名空间: Microsoft.Office.Interop.InfoPath.SemiTrust
程序集: Microsoft.Office.Interop.InfoPath.SemiTrust(位于 Microsoft.Office.Interop.InfoPath.SemiTrust.dll 中)
语法
声明
ReadOnly Property NewValue As Object
Get
用法
Dim instance As DataDOMEvent
Dim value As Object
value = instance.NewValue
Object NewValue { get; }
属性值
备注
NewValue 属性所包含的 XML DOM 节点的值将替换现有值。若要获取 XML DOM 节点的原始值,请使用 OldValue 属性。
重要
此成员只能由与当前打开的表单在相同域中运行的表单访问,或者由已授予跨域权限的表单访问。
示例
下列示例使用 DataDOMEventObject 对象的 OldValue 属性显示 XML DOM 节点的原始值,及其 NewValue:
thisXDocument.UI.Alert("Original value: " + e.OldValue.ToString() + "\nNew value: " + e.NewValue.ToString());
在以下示例中,检查 DataDOMEvent 的 NewValue 属性是否为空值。如果不为空,则清除"FirstName"和"Lastname"域。
if (e.IsUndoRedo)
{
// An undo or redo operation has occurred and the DOM is read-only.
return;
}
// A field change has occurred and the DOM is writable. Write code here to respond
// to the changes.
if (e.NewValue.ToString() == "")
return;
if (thisXDocument.DOM.selectSingleNode("/dfs:myFields/dfs:queryFields/q:Employees/@FirstName").text != "")
thisXDocument.DOM.selectSingleNode("/dfs:myFields/dfs:queryFields/q:Employees/@FirstName").text = "";
if (thisXDocument.DOM.selectSingleNode("/dfs:myFields/dfs:queryFields/q:Employees/@LastName").text != "")
thisXDocument.DOM.selectSingleNode("/dfs:myFields/dfs:queryFields/q:Employees/@LastName").text = "";