This documentation is archived and is not being maintained.

ButtonEvent.Clicked Event (Microsoft.Office.InfoPath)

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

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

public abstract event ClickedEventHandler Clicked

Exception typeCondition


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!");