Defining navigators in a CLASS.cs file - InfoPath Dev
in

InfoPath Dev

Defining navigators in a CLASS.cs file

Last post 07-30-2010 12:19 AM by alexia_net. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 07-29-2010 04:17 AM

    Defining navigators in a CLASS.cs file

    Hi. I am trying to define some navigators in a CLASS.cs file, not in the main  FORMCODE.cs file, and I am having some problems with this. This is how I define them:

               XPathNavigator objMain = this.MainDataSource.CreateNavigator();
                XPathNavigator objSec = this.MainDataSource.CreateNavigator();

    The error is:

     'tmplReportConnections.ListsTablesMessagesFunctions' does not contain a definition for 'MainDataSource'
     

    If i define them in the FORMCODE.cs, which is the main file of the program, all is ok. The same with the variable bellow.

                    string myNameSpace = "";
                    myNameSpace = NamespaceManager.LookupNamespace("my");

     

    I have also tried like this, to connect it to the mainform somehow:

                 FormCode objFormCode = new FormCode();

                //create navigators
                XPathNavigator objMain = objFormCode.MainDataSource.CreateNavigator();
                XPathNavigator objSec = objFormCode.MainDataSource.CreateNavigator();

                    string myNameSpace = "";

                    myNameSpace = objFormCode.NamespaceManager.LookupNamespace("my");

     In this case the error is:

      No overload for method 'FormCode' takes '0' arguments 
     

    How should i define them in a CLASS.cs file? Thank you!

  • 07-29-2010 07:50 AM In reply to

    Re: Defining navigators in a CLASS.cs file

    You need to find a way to pass the MainDataSource variable to the code in your Class.cs file from the code in FormCode.cs.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 07-29-2010 11:14 PM In reply to

    Re: Defining navigators in a CLASS.cs file

     Hi Jimmy, I know that, I just do not know what type the object should be. Thanks.

  • 07-29-2010 11:25 PM In reply to

    Re: Defining navigators in a CLASS.cs file

     Well, I have passed the XpathNavigators from the mainform.cs to class1.cs and it works; I suppose i have to do the same with NamespaceManager.

  • 07-29-2010 11:31 PM In reply to

    Re: Defining navigators in a CLASS.cs file

    Have you tried passing the this variable as an XmlFormHostItem to class1?  That should contain everything you need.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 07-29-2010 11:56 PM In reply to

    Re: Defining navigators in a CLASS.cs file

     Hi Jimmy. In order to transfer the namespacemanager to the class.cs1 i have defined in the main file a variable

    XmlForm objNSManager;

    but when i try to send it through the function i get this error saying:

    Use of unassigned local variable

    I have tried severel way to initialize it but no luck. Could you tip me on this? Thank you.

  • 07-29-2010 11:57 PM In reply to

    Re: Defining navigators in a CLASS.cs file

     No i have not tried this. I will try and get back. Thanks.

  • 07-30-2010 12:19 AM In reply to

    Re: Defining navigators in a CLASS.cs file

     Thank you Jimmy. That helps a lot.

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