当前位置:编程学习 > C#/ASP.NET >>

WeifenLuo Document窗口问题。

MainForm中的如下代码可以正常使用:
private void menuItemNew_Click(object sender, System.EventArgs e)
{
            DummyDoc dummyDoc = CreateNewDocument();
            if (myDockPanel.DocumentStyle == DocumentStyle.SystemMdi)
            {
                dummyDoc.MdiParent = this;
                dummyDoc.Show();
            }
            else
            {
                dummyDoc.Show(myDockPanel);
            }
}
在MainForm中有一个方法:
public void OpenText(string filePath)
        {
menuItemNew_Click(null,null);
}
在MainForm中也可以正常调用,但现在我想根据SolutionExplorer中的内容打开不显示不同内容document窗口,做法如下:
Assembly assem = Assembly.LoadFrom("DockSample.exe");
            Type ht = typeof(MainForm);

            Object obj = Activator.CreateInstance(ht);

            string filePath = @"c:\a.txt";

            MethodInfo OpenText= ht.GetMethod("OpenText");
            Object[] para = { filePath };
            OpenText.Invoke(obj, para);
这时即不报错,document窗口也不出现,不知道什么原因,请指教。 --------------------编程问答-------------------- Assembly assem = Assembly.LoadFrom("DockSample.exe");
            Type ht = typeof(MainForm);

            Object obj = Activator.CreateInstance(ht);

            string filePath = @"c:\a.txt";

            MethodInfo OpenText= ht.GetMethod("OpenText");
            Object[] para = { filePath };
            OpenText.Invoke(obj, para);

以上代码是在SolutionExplorer中,采用反射。
--------------------编程问答-------------------- 希望有朋友指点,项目很急,多谢。 --------------------编程问答-------------------- 自己顶下。 --------------------编程问答-------------------- up --------------------编程问答-------------------- 很好奇,记录下来了
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,