Microsoft Office Tutorials and References
In Depth Information
The InfoPath Changed event is activated when the form (or elements on the InfoPath
form) has been changed.
fieldname_Changed(object sender, XmlEventArgs e)
The Changed event is normally used for changing data in an InfoPath form
corresponding to other changes happening in the same InfoPath form. Consider
an example where, once the total is changed, the message gets written to the user
interface with both the old value and the new value. We write the functionality for
the changed event of the field, as shown below.
public void fieldname_Changed(object sender, XmlEventArgs e)
string StrManagerName = "";
// Check if value has changed and not a table insertion
if (e.Operation == XmlOperation.ValueChange)
// Get Current Row
XPathNavigator xNavigator = e.Site;
bool bParent = xNavigator.MoveToParent();
// Get Reference to the Gross Value
XPathNavigator xField = xNavigator.SelectSingleNode("/my:
StrValue = xField.InnerXml;
// Create a Navigator object to access the main DOM
XPathNavigator xDoc = this.MainDataSource.CreateNavigator();
// Create a Navigator object for the field that you want to set
XPathNavigator xData = xDoc.SelectSingleNode("/my:Report
// Set old and newly changed manager names
xData.SetValue("Old Total: " + e.OldValue.ToString() + " &
New Value: " + e.NewValue.ToString());
You can use the Changing event to address advanced data validation requirements.
This event occurs after the Validate event is activated. During the Changing event,
the form's underlying XML document is placed in read-only mode.
fieldname_Changing(object sender, XmlChangingEventArgs e)