Adding optional sections in code - InfoPath Dev
in

InfoPath Dev

Adding optional sections in code

Last post 07-10-2006 07:27 PM by Matt Faus. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 07-10-2006 04:33 PM

    • djay
    • Top 500 Contributor
    • Joined on 06-06-2006
    • Posts 35

    Adding optional sections in code

    I'm adding an optional section in C#. I can't use executeAction so I'm using appendChild with the xml I got out of sampledata.xml

    The problem is that I have optional sections within this optional section and I want them to remain hidden. Is there a way to add this optional section without adding it's children?
  • 07-10-2006 06:58 PM In reply to

    • SamDahl
    • Top 500 Contributor
    • Joined on 03-28-2006
    • Australia
    • Posts 44

    Re: Adding optional sections in code

    Tried adding the section and then hiding the subsection? just a thought...

    GL
  • 07-10-2006 07:27 PM In reply to

    Re: Adding optional sections in code

    You can remove the child section before adding the parent. It would go something like this:

    IXMLDOMDocument2 tempdom = (IXMLDOMDocument2)thisXDocument.CreateDOM();
    tempdom.async = false;
    tempdom.validateOnParse = false;
    tempdom.load( "sampledata.xml" );

    IXMLDOMNode nToAdd = tempdom.documentElement.selectSingleNode( "/group1/group2" );

    IXMLDOMNode nToDelete = nToAdd.selectSingleNode( "group3" );
    nToDelete.parentNode.removeChild( nToDelete );

    // Now add it to the Main DOM and it won't have that child section (i.e. will be hidden)
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.