New Form Different View - InfoPath Dev
in

InfoPath Dev

New Form Different View

Last post 04-16-2010 09:22 AM by Hilary Stoupa. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 04-15-2010 07:56 AM

    • Lawson
    • Top 100 Contributor
    • Joined on 12-24-2009
    • Virginia
    • Posts 91

    New Form Different View

    I have an IP 2003 form with C# code. I would like to add a button that will open up a new form in a different view.

    I am using the following code:

    XDocument NewForm = thisApplication.XDocuments.NewFromSolution(@"C:\Users\Lawson\Desktop\Switch View.xsn");

    thisXDocument.View.SwitchView("View 2");

    This code opens a new form, but it doesn't change the view in the new form.

    Any suggestions?

    Thanks,

    -Lawson

  • 04-15-2010 08:22 AM In reply to

    Re: New Form Different View

    try

    NewForm.View.SwitchView("View2")

    EDIT: It seems views are not loaded uptill this point so can not be changed, however there might be some cool workaround which i dont know

    Qazi Anis
    Technical Architect
    Bitwise Inc
  • 04-15-2010 04:23 PM In reply to

    • Lawson
    • Top 100 Contributor
    • Joined on 12-24-2009
    • Virginia
    • Posts 91

    Re: New Form Different View

    I get a "COMexception was unhandled by user code"

     

  • 04-16-2010 09:22 AM In reply to

    Re: New Form Different View

    Ah, I see by Qazi's edit that the views aren't loaded at this point. You have your NewForm variable -- you might want to try adding a field to the form and then, in your code, set the value of the field. Set a rule on the field to switch views -- you can make that rule conditional, only set it when you open from code (thus, it has the value you set in your code), add a rule to clear the field after you switch the view. Not sure if it will work, but might be worth a try!

    Hilary Stoupa

Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.