Visio control is resetting to old data when show() is called
I have a project which contains multiple forms that have a microsoft visio activex control in them. For some reason they keep interfering with one another. Here's a snip it of my code, simplified:
private void OpenRDM()
{
if (RDMform == null)
{
// Constructor opens a new form, and populates a Visio control on it
RDMform = new RDM.MainForm();
}
RDMform.Show();
}
private void OpenPSM()
{
if (PSMform == null)
{
// Constructor opens a new form, and populates a Visio control on it
PSMform = new PSM.MainForm();
}
PSMform.Show(); // Problem occurs here, PSM Visio control gains contents of RDM's Visio Control
}
public void main()
{
OpenRDM();
RDMform.Hide();
OpenPSM();
PSMForm.Hide();
}
I can call one of these functions and it works fine, but if I hide the form, and then call the other one, its Visio control loads with the contents of the first form, instead of the correct new stuff. I traced it, and the second Visio control is populated just fine, until the second Show() method is called, at which point it mysteriously goes back to the contents of the first Visio control.
I can't figure out what is going on here, Visio seems to think that they are the same control.
Edit* In response to comment about setting the .src property. The source is a behemoth, so I can't reasonably post everything it does. But here's those lines. in RDM:
If visioControl.Src <> TemplateFullName Then
visioControl.Src = TemplateFullName
Else
visioControl.Src = ""
visioCo开发者_开发技巧ntrol.Src = TemplateFullName
End If
in PSM:
drawingControl.Src = string.Empty;
drawingControl.Src = vstFilepath;
InitializeFlowDiagram(dbFilepath); // updates shapes from database values
Both modules actually use the same visio diagram including page names, they just display it in different ways. So I'd like to be able to back and forth between them without having to reload everything. Maybe the activeWindow is involved in the problem, I'll have to do more research.
精彩评论