views:

33

answers:

1

I need to provide the equivalent of a hyperlink to open a new infopath form within my UI. However, that is all that the button should do - open the correct form by filepath, in InfoPath, and then the reference should be dropped.

Does anyone know how to do this?

Thanks!!

badPanda

A: 
void mDisplayForm_Click(object sender, EventArgs e)
    {
        int count = 0;
        foreach (ToolStripMenuItem template in mDisplayForms)
        {
            if (sender.ToString() == template.Text)
            {
                Process infoPath = new Process();
                infoPath.StartInfo.FileName = "InfoPath.exe";
                infoPath.StartInfo.Arguments = templates[count];
                infoPath.Start();
                count++;
            }
        }
    }

This is the code I used to solve the problem.

badpanda
Hmm, the check of template.Text doesn't semantically link to the assignment of templates[count] (backing model?) to Arguments, does it? Maybe you have to count up (but there's no order guarantee in a foreach-loop afaik) regardless of whether the check was successful or not.
Andreas
Hmmm. Experimentally....the indices align. However, I will ask because neither MSDN nor any other forums I see have any definitive answer on the subject.
badpanda