using System;
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.Data;
 using System.Drawing;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 using System.Windows.Forms;

 namespace WindowsFormsApplication1
 {
     public partial class Form1 : Form
     {
         private string name;
         public Form1()
         {
             InitializeComponent();
         }

         private void button1_Click(object sender, EventArgs e)
         {
             Form2 frm2 = new Form2();
             frm2.MdiParent = this;
             frm2.Show();
         }

         private void button2_Click(object sender, EventArgs e)
         {
             Form3 frm1 = new Form3();
             frm1.MdiParent = this;
             frm1.Show();
         }
         public event Action<string> OnText;
         public void ToChangeText(string obj)
         {
             if (OnText != null)
             {
                 OnText(obj);}
         }
         private void Form1_Load(object sender, EventArgs e)
         {

         }
     }
 }
 using System;
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.Data;
 using System.Drawing;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 using System.Windows.Forms;

 namespace WindowsFormsApplication1
 {
     public partial class Form2 : Form
     {
         public Form2()
         {
             InitializeComponent();
         }

         private void button1_Click(object sender, EventArgs e)
         {
             (this.ParentForm as Form1).ToChangeText("form2来的消息啊?");
         }
     }
 }
 using System;
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.Data;
 using System.Drawing;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 using System.Windows.Forms;

 namespace WindowsFormsApplication1
 {
     public partial class Form3 : Form
     {
         public Form3()
         {
             InitializeComponent();
         }

         private void Form3_Load(object sender, EventArgs e)
         {
             MessageBox.Show(this.ParentForm.Name);
             (this.ParentForm as Form1).OnText += new Action<string>(Form3_OnText);
         }
         private void Form3_FormClosed(object sender, FormClosedEventArgs e)
         {
             (this.ParentForm as Form1).OnText -= new Action<string>(Form3_OnText);
         }
         void Form3_OnText(string obj)
         {
             textBox1.Text = textBox1.Text+obj;
         }
     }
 }

C# MDI子窗体互相操作的更多相关文章

  1. 用DLL方式封装MDI子窗体

    用DLL方式封装MDI子窗体是一种常用的软件研发技术,他的长处: 研发人员能够负责某一个模块的编写包括(界面+逻辑),能够互不干扰,模块研发完成后,主程式统一调用. 易于程式升级,当程式升级时,不用编 ...

  2. 解决WinForm(C#)中MDI子窗体最大化的问题

    “用MDI方式打开一个子窗口体后,总是不能最大化显示,明明子窗口体的WindowState设置为Maximized?”,相信有很多人会遇到这的样问题,请按下面的方法设置即可使MDI子窗体最大化: 1. ...

  3. Delphi中实现MDI子窗体(转)

        Delphi中实现MDI子窗体 用MDI实现浏览子窗口,具有窗口管理功能,同屏观看多个网页的内容  ① 多文档窗体(MDI) MDI窗体是一种具有主子结构的窗体体系,微软的Word便是其中的一 ...

  4. 保证相同类型的MDI子窗体只会被打开一次的方法

    本文转载:http://www.cnblogs.com/Ricky81317/archive/2008/09/17/1292443.html 看到论坛中有朋友问,如何可以保证在MDI主窗体中,同一类型 ...

  5. 在DLL动态链接库中封装VCL的MDI子窗体

    在DLL动态链接库中封装VCL的MDI子窗体不多说了,看代码就应该明白了,曾经我遇到的问题,现在放出来大家共享! 这里是工程文件的部分: 在DLL中封装MDI子窗体需要重写DLL入口函数,具体代码如下 ...

  6. Delphi MDI 子窗体的创建和销毁 [zhuan]

    1.如果要创建一个mdi child,先看是否有这个child 存在,如果有,则用它,如果没有再创建 //该函数判断MDI 子窗体是否存在,再进行创建和显示function isInclude(for ...

  7. 解决WinForm(C#)中MDI子窗体最大化跑偏的问题

    “用MDI方式打开一个子窗口体后,总是不能最大化显示,明明子窗口体的WindowState设置为Maximized?”,相信有很多人会遇到这的样问题,请按下面的方法设置即可使MDI子窗体最大化: 1. ...

  8. C# 设置MDI子窗体只能弹出一个的方法

    Windows程序设计中的MDI(Multiple Document Interface)官方解释就是所谓的多文档界面,与此对应就有单文档界面 (SDI), 它是微软公司从Windows .0下的Mi ...

  9. Ribbon 窗体的 MDI 子窗体使用 TabbedMDIManager 切换时工具条闪屏问题的解决办法

    补充说明: 此问题已经在新版本中解决(15.2.6),方法更加简单,只需要在 MDIChild 窗体的 Create 方法中,将 Ribbon 的 Visible 属性设置为 false 就可以了,且 ...

随机推荐

  1. button按钮波纹,箭头特效css

    波纹特效: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <tit ...

  2. 使用tomact监控应用服务器的性能

    第一步:在D:\apache-tomcat-7.0.63\conf 配置目录找到tomcat-users.xml 打开添加用户角色及权限 第二步:重启tomact 第三步:浏览器上打开http://1 ...

  3. sqlserver索引小结

    1.1 什么是索引? SQL索引有两种,聚集索引和非聚集索引,索引主要目的是提高了SQL Server系统的性能,加快数据的查询速度与减少系统的响应时间 下面举两个简单的例子: 图书馆的例子:一个图书 ...

  4. AT常见问题

    https://m.douban.com/note/247040789/?from=author

  5. 【leetcode】Unique Binary Search Trees (#96)

    Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For examp ...

  6. CompletionService/ExecutorCompletionService/线程池/concurrent包

    线程池 线程池的基本思想:线程频繁的创建.销毁会极大地占用系统资源,为了减少系统在创建销毁线程时的开销,线程池应运而生.线程池包括多个已创建的线程,当有任务要在新线程中执行时,将任务提交给线程池,线程 ...

  7. Spring+SpringMvc+Mybatis整合注意事项

    1.web.xml代码如下 <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi ...

  8. POJ 2251 题解

    Dungeon Master Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 27520   Accepted: 10776 ...

  9. poj2104 K-th Number区间第k小值 主席树

    原来主席树就是可持久化线段树啊,刚知道,,, 作为一道裸题,还是必A的,然而一开始偷懒不写离散化跪了N多遍,后来在缪大的帮助下发现了这个问题,遂A之 ——又是这种破问题,实在不想说自己了 把n个数看成 ...

  10. SQL中对于两个不同的表中的属性取差集except运算

    SQL中对两个集合取差集运算,使用except关键字,语法格式如下: SELECT column_name(s) FROM table_name1 EXCEPT SELECT column_name( ...