Copy rich text field with formatting - InfoPath Dev
in

InfoPath Dev

Copy rich text field with formatting

Last post 09-02-2005 07:58 AM by Coita Thierry. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 08-29-2005 07:37 AM

    Copy rich text field with formatting

    Hi,

    I wan't to copy in c# code the rich text field(RTF) in the Secondary data source(SDS) to my RTF in the Primary data source (PDS) without lost my formatting! Is it possible?

    What I have try:

    IXMLDOMNode jean = oDomSearchHRG.selectSingleNode("/tabMuster/Muster/Text[position()=1]");
    IXMLDOMNode jean2= thisXDocument.DOM.selectSingleNode("/my:myFields/my:group3/my:group4/my:field9");
    jean2.parentNode.replaceChild(jean, jean2);


    That make me an error because the node is Text in the SDS and my:field9 in the PDS.

    or

    jean2.replaceChild(jean, jean2);


    that make me this error:
    quote:
    System.ArgumentException
    Insert position Node must be a Child of the Node to insert under.

    at Microsoft.Office.Interop.InfoPath.SemiTrust.IXMLDOMNode.replaceChild(IXMLDOMNode newChild, IXMLDOMNode oldChild)
    at Microsoft.Office.Interop.InfoPath.SemiTrust.DOMNodeWrapper.replaceChild(IXMLDOMNode newChild, IXMLDOMNode oldChild)
    at Microsoft.Office.Interop.InfoPath.SemiTrust.DOMNodeWrapper.replaceChild(IXMLDOMNode newChild, IXMLDOMNode oldChild)
    at testmuster.testmuster.field9_OnAfterChange(DataDOMEvent e)
    in c:\documents and settings\tc\bureau\st gallen\visual studio
    projects\testmuster\formcode.cs:line 50
    at Microsoft.Office.Interop.InfoPath.SemiTrust._DataDOMEventSink_SinkHelper.OnAfterChange(DataDOMEvent pDataDOMEvent)




    How can I proceed to copy my value with my formating (bold, strike, color, etc (no table ,no image))?

    Thanks in advance

    ++

    Thierry

    Every moment hesitated is a moment gone for life!!! Think about it
    Infopath 2007, Langage: C#2.0 (Modèle Objet 2003)
    merci de lire ceci
  • 09-01-2005 10:13 AM In reply to

    Re: Copy rich text field with formatting

    The easiest fix is to make sure that both the Main DOM and 2DS have the same field name (including the same namespace). Even if both were named "Text" if one was "Text" and the other was "my:Text" replaceChild would still not work because they have to be the same fully qualified name (i.e. the namespace must match too).

    But you don't always have the capability to make both match.

    I don't recall if the Node.xml attribute is read/write or readonly. If it is read/write you might be able to do something like jean2.xml = jean.xml. You'll have to look into that.

    Other than that I can't think of anything right now that would work. I'm sure there some way to do it though, even if it means loading a custom XSL to transform the one into the other before doing the replaceChild.

    Greg Collins [InfoPath MVP]
    InfoPath Dev
  • 09-02-2005 07:58 AM In reply to

    Re: Copy rich text field with formatting

    Ok I will try next week!

    Thanks for the three solution!

    ++

    Thierry

    Every moment hesitated is a moment gone for life!!! Think about it
    Infopath 2007, Langage: C#2.0 (Modèle Objet 2003)
    merci de lire ceci
Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.