非委托/利用委托
网上搜索的关于C#的文章多得不胜枚举,但没有一篇是实用的,本人的实实在在绝对能运行,解决父子窗口通信问题,mdi窗口问题,而且简单易懂.......
《1》
我们这里假设已经存在了两个窗体分别为:FormFather(父窗体)(父窗体的IsMdiContainter要设置为true)和FormChild(子窗体),而父窗体中有一个名为Btn_OpenChild的按钮,用来打开子窗体,子窗体中也有个名为Btn_IsTrue按钮和一个TextBox控件。当TextBox控件中输入“True”时,父窗体的Btn_OpenChild可用,并关闭子窗体,当输入其它任何字符或字符串父窗体的Btn_OpenChild都不可用而不关闭子窗体,当然刚启动程序时的父窗体的Btn_OpenChild按钮是可用的。下面是实现的代码:
1//下面是主窗体的代码
2using System;
3using System.Collections.Generic;
4using System.ComponentModel;
5using System.Data;
6using System.Drawing;
7using System.Text;
8using System.Windows.Forms;
9
10namespace MDIFormDemo
11{
12 public partial class FormFather : Form
13 {
14 public FormFather()
15 {
16 Initialize