How to access form object? - InfoPath Dev
in

InfoPath Dev

How to access form object?

Last post 03-07-2007 10:40 AM by Greg Collins. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 03-06-2007 04:43 AM

    • mrudula
    • Top 500 Contributor
    • Joined on 02-14-2007
    • India
    • Posts 31

    How to access form object?

    Hi All,

    I am trying to add control on InfoPath form through coding (c# language VSTO) but couldnt do it. I am not able to fetch Active form in the project.

    Form frm=Form.ActiveForm; //line 1
    frm.Controls.Add(tb);//tb=control object line 2

    line1 returns NULL in the frm so couldnt able to add control on the collection of controls on form.

    Can you please help me out? Wheather my approach is right or we need to follow some other approach?

    Thanks in advance.

    Regards,
    Mrudula
  • 03-06-2007 12:14 PM In reply to

    Re: How to access form object?

    You cannot dynamically add controls to the form. Add it in the designer, and use conditional formatting to choose when to show it.
  • 03-06-2007 10:39 PM In reply to

    • mrudula
    • Top 500 Contributor
    • Joined on 02-14-2007
    • India
    • Posts 31

    Re: How to access form object?

    Hi Greg,

    But then How do I show table data on repeating table or any other control as my table is changing always and want to show data as report.

    I want to show data from table on form, I only know the tablename. Table columns are going to change as table changes so I want some datagrid kind of control on InfoPath which will dynamically change columns and rows which would help me to write in less code.

    Cannot I add/append child on repeating section and use this child as columns. And then add rows to it which would be same as datagrid then?

    Thanks in advance.

    Regards,
    Mrudula
  • 03-07-2007 04:39 AM In reply to

    Re: How to access form object?

    Yes you can do that of course. I guess what Greg ment is more that you cannot create any control out of nothing with infopath you can however append new childs to an existing node, see this for example for a repeating section:

    string myRepeat	= thisXDocument.DOM.selectSingleNode("my:myFields/my:Result/my:Results").xml;
    IXMLDOMDocument oXml = thisXDocument.CreateDOM();
    oXml.async = false;
    oXml.loadXML(myRepeat);
    IXMLDOMNode parentNode = thisXDocument.DOM.selectSingleNode("my:myFields/my:Result");
    parentNode.appendChild(oXml.documentElement);


    But anyway if your repeating table/section is bound to a secondary datasource (database) it will expand automatically.

    Does this help ?
    Listen to Motörhead cos they play Rock'n Roll :)
  • 03-07-2007 10:40 AM In reply to

    Re: How to access form object?

    Correct - rows are dynamic... they can be added, removed, whatever. Or in the case of InfoPath 2007, you can use the horizontal control which allows columns to be dynamic. But there is no control which allows both columns and rows to be dynamic. InfoPath 2003 only supports dynamic rows (unless you hack the XSL to make it dynamic columns).

    What you are likely to end up with is a table which has all the required columns (though some might be blank because no values is provided as the column doesn't physically exist in the data), and dynamic rows.
Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.