ButtonEvent.Clicked Event
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Occurs when a Button control is clicked within a view in a form.
public:
abstract event Microsoft::Office::InfoPath::ClickedEventHandler ^ Clicked;
public abstract event Microsoft.Office.InfoPath.ClickedEventHandler Clicked;
member this.Clicked : Microsoft.Office.InfoPath.ClickedEventHandler
Public MustOverride Custom Event Clicked As ClickedEventHandler
Event Type
Exceptions
Only one delegate can be added to the event. This exception is thrown if multiple delegates are added for the same Control ID.
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(String) 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
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.