locked
ProjectItem Template: InvokeMember on Control in DesignMode from IWizard.RunFinished() ? RRS feed

  • Question

  • Hi

    I have a template that creates a user control, which contains a 3rd-party grid control (Janus GridEX), which has a design-time method (Verb?) "RetrieveStructure" which sets up the grid columns based on the data source.

    I have code to call this method from the RunFinished() method in my IWizard implementation:

     

    public void

    RunFinished()

    {

     

    IDesignerHost host = _dte2.ActiveDocument.ActiveWindow.Object as IDesignerHost

    ;

     

    Control control = host.RootComponent as Control

    ;

     

    Control gridex = control.Controls.Find("MainGrid", true

    )[0];

     

    Type

    t = gridex.GetType();

    t.InvokeMember(

    "RetrieveStructure", System.Reflection.BindingFlags.InvokeMethod, null, gridex, new object[]{false

    });

    }

    This appears to work (i.e. the designer shows the new column layout while the wizard is running), but then it reverts to the original layout once the wizard has finished and control is returned to the IDE.

    Is there some other way of calling a design-time method from my wizard?

     

    Thursday, December 1, 2011 1:03 AM

Answers

  • Hi Yi

    I added the Project.Save call at the end of the RunFinished code, but it didn't help.

    I did solve the problem though:

    The display settings are serialized to the user control's *.resx, which gave me an idea - I removed the *.resx file from the template, forcing the IDE to create a new one when it saved, and bingo! problem solved.

    I'm not sure if the modified *.resx is being overwritten by the original template version at some point after RunFinished, or whether the GridEX control did not yet serialize the new layout before the IDE 'refreshed' which may have forced the GridEX to reload the original serialized layout.

    Thanks for getting me to think about where it was storing the settings :-)

     

    • Proposed as answer by Yi Feng Li Monday, December 5, 2011 3:02 AM
    • Marked as answer by Yi Feng Li Monday, December 12, 2011 2:56 AM
    Thursday, December 1, 2011 11:53 PM

All replies

  • Hi

    RunFinished method is to implement custom wizard logic when the wizard has completed all tasks. Based on the information, the automation action works but reverts back after the wizard, which looks like changes made by your automation are not saved.

    I believe the RunFinished is the right place to do such automation. However, we don’t know much of the logical about what the function RetrieveStructure did exactly. Where did the control store the display settings? I think we can debug the code to find the root cause of this issue.

    If we call Project.Save to save the relative project after the automation call, does it work?

     

    If I misunderstand you, please let me know.

     

    Regards,

    Yi


    Yi Feng Li [MSFT]
    MSDN Community Support | Feedback to us
    Thursday, December 1, 2011 6:20 AM
  • Hi Yi

    I added the Project.Save call at the end of the RunFinished code, but it didn't help.

    I did solve the problem though:

    The display settings are serialized to the user control's *.resx, which gave me an idea - I removed the *.resx file from the template, forcing the IDE to create a new one when it saved, and bingo! problem solved.

    I'm not sure if the modified *.resx is being overwritten by the original template version at some point after RunFinished, or whether the GridEX control did not yet serialize the new layout before the IDE 'refreshed' which may have forced the GridEX to reload the original serialized layout.

    Thanks for getting me to think about where it was storing the settings :-)

     

    • Proposed as answer by Yi Feng Li Monday, December 5, 2011 3:02 AM
    • Marked as answer by Yi Feng Li Monday, December 12, 2011 2:56 AM
    Thursday, December 1, 2011 11:53 PM
  • Hi Demarchist,

    Thank you for your update and we are glad to know the issue is resolved.

    Yi


    Yi Feng Li [MSFT]
    MSDN Community Support | Feedback to us
    Monday, December 5, 2011 3:02 AM