C# 动态创建出来的窗体间的通讯 delegate2
附件:http://files.cnblogs.com/xe2011/CSharp_WindowsForms_delegate02.rar
窗体2 和窗体3 都是动态创建出来的
现在 FORM3.TEXT要即时 = FORM2.TEXT
FORM1窗体代码
Form2 f2 = new Form2();
Form3 f3 = new Form3();
private void Form1_Load(object sender, EventArgs e)
{
f2.XYZ += new Form2.CallBack(GetForm2TextBox1Text); f2.Dock = DockStyle.Fill;
f2.TopLevel = false;
f2.FormBorderStyle = FormBorderStyle.FixedToolWindow;
f2.Parent = panel1;
f2.Show(); f3.Dock = DockStyle.Fill;
f3.TopLevel = false;
f3.FormBorderStyle = FormBorderStyle.FixedToolWindow;
panel2.Controls.Add(f3);
f3.Show();
} private void GetForm2TextBox1Text(string s)
{
f3.textBox1.Text = s;
}
FORM2窗体代码
public delegate void CallBack(string s);
public event CallBack XYZ; private void textBox1_TextChanged(object sender, EventArgs e)
{
XYZ(textBox1.Text);
}
FORM3窗体代码
无
FORM1窗体代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms; namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} Form2 f2 = new Form2();
Form3 f3 = new Form3();
private void Form1_Load(object sender, EventArgs e)
{
f2.XYZ += new Form2.CallBack(GetForm2TextBox1Text); f2.Dock = DockStyle.Fill;
f2.TopLevel = false;
f2.FormBorderStyle = FormBorderStyle.FixedToolWindow;
f2.Parent = panel1;
f2.Show(); f3.Dock = DockStyle.Fill;
f3.TopLevel = false;
f3.FormBorderStyle = FormBorderStyle.FixedToolWindow;
panel2.Controls.Add(f3);
f3.Show();
} private void GetForm2TextBox1Text(string s)
{
f3.textBox1.Text = s;
}
}
}
FORM2窗体代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms; namespace WindowsFormsApplication1
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
} public delegate void CallBack(string s);
public event CallBack XYZ; private void textBox1_TextChanged(object sender, EventArgs e)
{
XYZ(textBox1.Text);
}
}
}
FORM3窗体代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms; namespace WindowsFormsApplication1
{
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
}
}
}
C# 动态创建出来的窗体间的通讯 delegate2的更多相关文章
- C# 动态创建出来的窗体间的通讯 delegate3
附件1:http://files.cnblogs.com/xe2011/CSharp_WindowsForms_delegate03.rar 一个RTF文件管理器 描述 Form2,Form3,For ...
- C# 动态创建出来的窗体间的通讯 delegate1
附件 http://files.cnblogs.com/xe2011/CSharp_WindowsForms_delegate01.rar 需要每个窗体是独立存在,禁止相与引用窗体 这样干净并且可以反 ...
- 自定义事件实现不同窗体间的通讯Delphi篇
要实现子窗体与父窗体之间的通讯,有多种方法(比如:重载子窗体的构造函数,将父窗体的引用作为参数传递给子窗体).下面我要介绍的是利用自定义事件的方法,它能够最大程度的避免模块之间的耦合,充分体现面向对象 ...
- C#窗体间传值的简便方法/工具
一.问题:窗体间传值必须需要窗体之间有联系,具体有如下方式 窗体间传值涉及到窗体A必须拥有窗体B,这样才可以实现A-B之间传值 窗体A与窗体B在窗体/实例C中,A-B可互相通讯 其他方式,不细讨论,复 ...
- C# 学习笔记(一) Winform利用Assembly反射动态创建窗体
1. 添加Reflection //添加对Reflection程序集引用 using System.Reflection; // 引用窗体创建方法CreateForm,传入参数 private voi ...
- Delphi中动态创建窗体有四种方式
Delphi中动态创建窗体有四种方式,最好的方式如下: 比如在第一个窗体中调用每二个,主为第一个,第二个设为动态创建 Uses Unit2; //引用单元文件 procedure TForm1.But ...
- c#反射动态创建窗体
根据窗体的名称动态创建窗体 Assembly assembly = Assembly.GetExecutingAssembly(); // 实例化窗体 try { Form f ...
- DELPHI动态创建窗体
//第一种方式 procedure TForm1.btn1Click(Sender: TObject); begin With TForm2.Create(Application) do Try Sh ...
- winform 用户控件、 动态创建添加控件、timer控件、控件联动
用户控件: 相当于自定义的一个panel 里面可以放各种其他控件,并可以在后台一下调用整个此自定义控件. 使用方法:在项目上右键.添加.用户控件,之后用户控件的编辑与普通容器控件类似.如果要在后台往窗 ...
随机推荐
- warning: no newline at end of file
编译错误:warning: no newline at end of file原因:程序结尾需要有一个空行解决办法:在程序末尾多打个回车就行了
- 定位 - MapKit - 基本使用
/** * Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Co ...
- Oracle XE修改默认HTTP端口8080
打开SQL*Plus控制台.用sys或者system登陆.然后运行: begin dbms_xdb.sethttpport('9999'); end; / 搞定.
- bzoj 3858: Number Transformation 暴力
3858: Number Transformation Time Limit: 1 Sec Memory Limit: 64 MBSubmit: 82 Solved: 41[Submit][Sta ...
- Sectong日志分析
http://tech.uc.cn/?p=2866#comments http://blog.sectong.com/blog/hw_bigdata.html
- 解决wordpress上传的文件尺寸超过 php.ini 中定义的 upload_max_filesize 值。
上传的文件尺寸超过 php.ini 中定义的 upload_max_filesize 值. 解决方法:修改/etc/php5/apache2/php.ini文件中的 post_max_size = 6 ...
- Android用户界面 UI组件--TextView及其子类(三) EditView以及各种Span文字样式讲解
EditView和TextView的用法差不多,只是文字可编辑 小技巧: 设置EditText隐藏键盘 setInputType(0); 设置EditText不被输入法遮盖 getWindow() ...
- WP e-Commerce WordPress Payment Gateways Caller插件本地文件包含漏洞
漏洞名称: WP e-Commerce WordPress Payment Gateways Caller插件本地文件包含漏洞 CNNVD编号: CNNVD-201310-642 发布时间: 2013 ...
- python 零散记录(三) 格式化字符串 字符串相关方法
使用 % 符号格式化字符串: """常用转换说明符:""" #%s: 按照str()方式转换 #%r: 按照repr()方式转换 #%d: ...
- AutoItLibrary
问题: [ ERROR ] Error in file 'E:\test\test_AutoItLibrary.txt': Initializing test library 'AutoItLibra ...