activex control with managed code: re-instantiated when value changes - InfoPath Dev
in

InfoPath Dev

activex control with managed code: re-instantiated when value changes

Last post 06-12-2007 07:21 AM by yellowseed. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 06-11-2007 02:03 PM

    activex control with managed code: re-instantiated when value changes

    I'm new to COM and have been working on a custom InfoPath control.  It's written in C#, implements the InfoPathControl interface, and generally works as expected  - Yay!  Sometimes, though, InfoPath "re-instantiates" the control.  It usually happens in response to ValueChanged events when the new value is not an empty string.  I've implemented the InfoPathControl interface as recommended by Roberts & Green:

    public void Enable(bool vfEnabled) { this.Enabled = vfEnabled; }
    public void Init(InfoPathControlSite pControlSite) { this.infoPathControlSite = pControlSite; }
    public void SaveState() { }
    public void Uninit() { this.infoPathControlSite = null; }

    Now I'm finding this.infoPathControlSite is set to null after these ValueChanged events, which is bad because I want to make changes to other column values in response to changes in this one.  Of course any suggestions are welcome (like: is it ok to use infoPathControlSite after Uninit has been called?), but this re-instantiating seems like a bug -- is it likely I'm doing something wrong?  Or does InfoPath treat all ActiveX controls this way?

    Thanks,
    -- Joshua
     

  • 06-12-2007 07:21 AM In reply to

    Re: activex control with managed code: re-instantiated when value changes

    Ah:

    Main reason for this issue is, whenever a data field that is bound to your ActiveX is changed, InfoPath destroys your control and create a new one. This is mainly because InfoPath has to apply your view xsl to your data source to create the view you see on the display. Every time data source changes, InfoPath re-applies the xsl file and creates the view from scratch for controls that are bound to changed data fields.

    Courtesy of the InfoPath Team blog: Creating Complex InfoPath Controls in C#.

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