Sharing Code Between Forms - InfoPath Dev
in

InfoPath Dev

Sharing Code Between Forms

Last post 10-26-2006 11:36 PM by Shiva. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 10-26-2006 11:13 AM

    Sharing Code Between Forms

    How can I access the same code from multiple forms? I don't want to copy and paste the same functions into the forms since this could become a maintenance headache.
    TIA
    Dean
    Dean
    Charlotte, NC
  • 10-26-2006 11:36 PM In reply to

    • Shiva
    • Top 25 Contributor
    • Joined on 04-15-2005
    • India
    • Posts 694

    Re: Sharing Code Between Forms

    Hi Dean,

    You can write all common methods in one class file and save this file as FileName.cs extension.

    For example: Your saved file namespace is “CommonFile” and class name is “Utilities”.

    Follow these below steps to your second solution file for adding above class file.

    1. Right click on Solution file and select “Add” - > “Add Existing Item” and select above class file (FileName.cs).
    2. Add a reference file to your code at the top by
    Using <CommonFile>;
    3. Inheritance your common file class using below code:
    public class SecondClassName : Utilities
    4. Add one line code in to the startup function as below
    base.Init(thisXDocument, thisApplication, CultureInfo.CurrentCulture);

    Note: The above code in C#
Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.