Microsoft Office Tutorials and References
In Depth Information
Writing event validation for an expense report form
The event handler for this event does not allow the user to cancel the event.
// Example for Click event to display date information.
public void btn_ClickEvent_Clicked(object sender, ClickedEventArgs e)
// Click event shows the message as current date.
System.DateTime sysDate = new DateTime();
Writing event validation for an expense
Let's work on a sample form and use some of the events available in Microsoft
Office InfoPath 2007. Let's start by creating a company expense report form, and
implementing the events for the validation of the user interface.
We are using most of the events available in InfoPath 2007 in the expense report for
some of the user interface validation.
1. Start Microsoft Visual Studio 2008.
2. On the File menu, click on New Project .
3. In the New Project dialog box, expand Visual C# project types .
4. Select New project . Under Office select 2007 , and select InfoPath 2007 Form
template. Name the project as per your requirements.
5. The Design Template dialog box is displayed. This is where you choose the
appropriate template for your design. In this example, we have selected the
Expense Report template.
6. Add the following code into the formcode.cs file.
public partial class FormCode
public void InternalStartup()
EventManager.FormEvents.Loading += new
EventManager.FormEvents.ContextChanged += new
my:managerEmailAddress"].Changing += new
my:managerName"].Changed += new