none
InfoPath 2010 FormState Issue RRS feed

  • Question

  • I am developing a form in Infopath 2010 using its native VSTO.

    I am trying to use FormState.  I have the code below right under the class specification.

     private int _currentYear
      {
       get
       {
        if (FormState["_currentYear"] != null)
         return (int)FormState["_currentYear"];
        else
         return 0;
       }
       set { FormState["_currentYear"] = value; }
      }

    And I am accessing it like this:

     

    FormState.Remove(_currentYear);
    
    FormState.Add(_currentYear, year);
    When I spin up the form in the debugger and I step through it drop into the Get for both the Forstat.Add and the FormState.Remove.  Anyone know what I am doing wrong here?

     


    M
    Thursday, July 14, 2011 8:34 PM

Answers

  • Hi Mario4272,
    Thanks for posting in the MSDN Forum.
    Due to you use a string as a identification of the collection. you must use "string" to access it.
    In this Issue, you will use ForumState.Add("_currentYear",year) and ForumState.Remove("_currentYear") to handle you access.
    I hope it can help you.
    have a good day,
    Tom

    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, July 19, 2011 8:42 AM
    Moderator