Compartir a través de


FormEvents.VersionUpgrade Event

Occurs when the version number of the form being opened is older than the version number of the form template on which it is based.

Namespace:  Microsoft.Office.InfoPath
Assembly:  Microsoft.Office.InfoPath (in Microsoft.Office.InfoPath.dll)

Syntax

'Declaration
Public MustOverride Event VersionUpgrade As VersionUpgradeEventHandler
'Usage
Dim instance As FormEvents
Dim handler As VersionUpgradeEventHandler

AddHandler instance.VersionUpgrade, handler
public abstract event VersionUpgradeEventHandler VersionUpgrade

Exceptions

Exception Condition
InvalidOperationException

The developer attempted to bind the event in some location other than the InternalStartup method.

Remarks

Important

The VersionUpgrade event is not meant to be instantiated by the developer in form code. You should only add event handlers for form-level events from the Microsoft InfoPath 2010 design mode user interface. When you add an event handler to your form template from the design mode user interface, InfoPath generates code in the InternalStartup method of your form code file using the EventManager class and the member of the FormEvents class to bind the event to its event handler. For information on how to add event handlers in InfoPath design mode, see How to: Add an Event Handler.

An event handler for the VersionUpgrade event allows you to run code to update a form when the form template on which it is based has been upgraded since the form was last opened.

The VersionUpgrade event is bound using the VersionUpgradeEventHandler delegate.

The VersionUpgrade event can be cancelled by using the CancelableArgs property of the VersionUpgradeEventArgs class to set the Cancel property to true.

This type or member can be accessed from code running in forms opened in Microsoft InfoPath Filler or in a Web browser.

Examples

In the following example, the DocumentVersion and FormTemplateVersion properties of the VersionUpgradeEventArgs class are used to display the version numbers of the form and form template.

public void FormEvents_VersionUpgrade(object sender, VersionUpgradeEventArgs e)
{
   MessageBox.Show("The form version: " + e.DocumentVersion + 
      "\nThe form template version: " + e.FormTemplateVersion);
   // Write code to update form here.
}
Public Sub FormEvents_VersionUpgrade(ByVal sender As Object, _
   ByVal e As VersionUpgradeEventArgs)
   MessageBox.Show("The form version: " & e.DocumentVersion & _
      vbNewLine & "The form template version: " & _
      e.FormTemplateVersion)
   ' Write code to update form here.
End Sub

See Also

Reference

FormEvents Class

FormEvents Members

Microsoft.Office.InfoPath Namespace