Clicked event
Collapse the table of content
Expand the table of content

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 abstract event ClickedEventHandler Clicked


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 void MyButton_Clicked(object sender, ClickedEventArgs e)
   XPathNavigator root, txtbox;
   root = this.MainDataSource.CreateNavigator();
   txtbox = root.SelectSingleNode("/my:myFields/my:field1", 
   txtbox.SetValue("Hello World!");
© 2016 Microsoft