Perhaps if I explain what I am trying to do a little better this will make more sense.
I have an InfoPath form that I want to have two sections. The first section contains text boxes that a user can input a name and address. The second section contains text and Expression Boxes that take the name and address and put them in certain sections of the text.
By default, only the first section is shown. I accomplish this by creating a new Data Source named "showInput" with a default value of "TRUE". I set the conditional formatting on the first section to be hidden when the value of "showInput" is "FALSE". The second section is hidden by default and is shown when the value of "showInput" is changed to "FALSE". I then use an export function to drop the current view into a PDF file.
It should work as follows:
-
User opens InfoPath form.
-
User only sees boxes to fill out information
-
User fills out information and presses the "Submit" button
-
The Submit button has custom code that changes the value of "showInput" from "TRUE" (the default) to "FALSE"
-
This change in value *should* make the input fields (contained in the first section) dissapear and the text with the values from the first section appear
-
The current view (which now sould only be the text) should be exported to a PDF
I have everything working except for the first section doesn't hide itself when the "showInput" value is set to "FALSE" even though I have the conditional formatting set to do so. Any ideas? My submit code is as follows:
using
Microsoft.Office.InfoPath;
using
System;
using
System.Windows.Forms;
using
System.Xml;
using
System.Xml.XPath;
using
mshtml;namespace NDA_Generic
{
public partial class FormCode
{
// Member variables are not supported in browser-enabled forms.
// Instead, write and read these values from the FormState
// dictionary using code such as the following:
//
// private object _memberVariable
// {
// get
// {
// return FormState["_memberVariable"];
// }
// set
// {
// FormState["_memberVariable"] = value;
// }
// }
// NOTE: The following procedure is required by Microsoft Office InfoPath.
// It can be modified using Microsoft Office InfoPath.public void InternalStartup()
{
EventManager.FormEvents.Submit += new SubmitEventHandler(FormEvents_Submit);
}
public void FormEvents_Submit(object sender, SubmitEventArgs e)
{
e.CancelableArgs.Cancel = false;
string fileName;XPathNavigator showInputControl = MainDataSource.CreateNavigator();if (showInputControl != null)
{
XPathNavigator showInput = showInputControl.SelectSingleNode("/my:myFields/my:showInput", NamespaceManager); if (showInput != null)
{
showInput.SetValue("False");
}
else
{
showInput.SetValue("True");
}
}
XPathNavigator nameNode = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:textName", NamespaceManager);if (nameNode != null && !String.IsNullOrEmpty(nameNode.Value))
{
fileName = nameNode.Value +
".pdf";this.CurrentView.Export(@"C:\Users\Richard\Desktop\" + fileName, ExportFormat.Pdf);
}
else
{
e.CancelableArgs.Cancel = true;
}
}
}
}