Share via


ButtonEvent.Clicked event

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)

Syntax

'Declaration
Public MustOverride Event Clicked As ClickedEventHandler
'Usage
Dim instance As ButtonEvent
Dim handler As ClickedEventHandler

AddHandler instance.Clicked, handler
public abstract event ClickedEventHandler Clicked

Exceptions

Exception Condition
InvalidOperationException

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

InvalidOperationException

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

Remarks

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

Note

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.

Examples

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", 
      this.NamespaceManager);
   txtbox.SetValue("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", _
      Me.NamespaceManager)
   txtbox.SetValue("Hello World!")
End Sub

See also

Reference

ButtonEvent class

ButtonEvent members

Microsoft.Office.InfoPath namespace