Hi,
Add a string field (field2) to the schema with the default value to 0. Add a text field to the schema and UI. Add a conditional formatting to this text field as if the field2 is not equal to 1 then hide the control. Now add the following code in the on context change event.
InfoPathEventHandler(EventType = InfoPathEventType.OnContextChange)]
public void FormEvents_OnContextChange(DocContextChangeEvent e)
{
if (e.Context.nodeName == "my:field1")
{
thisXDocument.DOM.selectSingleNode("/my:myFields/my:field2").text = "1";
}
if (e.Type == "ContextNode")
{
// The XML selection or context has changed.
// Write your code here.
return;
}
}
Here field1 -> first text box