zoukankan      html  css  js  c++  java
  • 在类库或winform项目中打开另一个winform项目的窗体

     假设类库或winform项目为A,另一个winform项目为B.那麽在A中添加一个接口,里面有一个Show方法,然后在B中写一个类b继承这个接口,并重写这个方法,具体内容为弹出某个窗体.然后在A中另一个类a中实例化B中的b类,并把它赋给A中的接口,然后调用接口的Show方法就可以弹出B中指定的窗体.

         需要注意的是项目A和项目B需要互相引入对方的EXE或DLL文件.

    转自:http://blog.csdn.net/a1027/article/details/2766396

    以下为代码部分:

     1 namespace His
     2 {
     3   public interface IShow
     4   {
     5     void Show();
     6   }
     7 }
    8 namespace EMRApp 9 { 10 public class CShow:IShow 11 { 12 public void Show() 13 { 14 Form frm = new Form(); 15 frm.Text = "测试EMRAPP窗口"; 16 frm.Show(); 17 } 18 } 19 } 20 21 namespace His 22 { 23 public class CTransfShow 24 { 25 public void aaa() 26 { 27 IShow ish = new CShow(); 28 ish.Show(); //here 29 } 30 } 31 }

    namespace His
    {
      public partial class Form1 : Form
      {
        public Form1()
        {
        InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
          CTransfShow ct = new CTransfShow();
          ct.aaa();
        }
      }
    }

  • 相关阅读:
    计算公司下班时间(娱乐)
    设计模式-观察者模式
    vue 打包后白屏的问题
    HashSet实现原理
    LinkedList实现原理
    ArrayList的实现原理
    HashMap实现原理分析
    深入理解java动态代理机制
    Spring工作原理
    数据库SQL优化大总结之 百万级数据库优化方案
  • 原文地址:https://www.cnblogs.com/yexiaoyanzi/p/4092410.html
Copyright © 2011-2022 走看看