ButtonEvent.Clicked event

Office 2013 and later

Occurs when a Button control is clicked within a view in a form.

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

Public MustOverride Event Clicked As ClickedEventHandler
Dim instance As ButtonEvent
Dim handler As ClickedEventHandler

AddHandler instance.Clicked, handler


Cannot bind the event in a location other than the InternalStartup method.


Only one delegate can be added to the event. This exception is thrown if multiple delegates are added for the same Control ID.

The event handler for this event does not allow cancelling the event.


The Clicked event raised by the Button control is the only event that is supported directly by a control on a form. However, the XmlEvent class implements events that are raised when changes are made to the underlying XML document of the form. With these events, you can create event handlers that respond to changes made from controls bound to nodes and groups in the underlying XML document of a form.

The following example assumes that you have a Button control and a Text Box control that is bound to field1 on your form. Clicking the Button opens a XPathNavigator object positioned at the root of the main data source of the form (the underlying XML document). This XPathNavigator is then used to select the node that the Text Box is bound to. It then sets and positions a second XPathNavigator for the Text Box to that node. Finally, the SetValue method of the XPathNavigator is used to set the Text Box to "Hello World!".

Public Sub MyButton_Clicked(ByVal sender As Object, _
   ByVal e As ClickedEventArgs)
   Dim root, txtbox As XPathNavigator
   root = Me.MainDataSource.CreateNavigator
   txtbox = root.SelectSingleNode("/my:myFields/my:field1", _
   txtbox.SetValue("Hello World!")
End Sub