C#窗口数据委托
namespace winlogin { public partial class Wdata : Form// 子窗口 { //委托事件 public delegate void TransfDelegate(Dictionary<string, string> value); public event TransfDelegate TransfEvent; //---------------------------- public Wdata() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Dictionary<string, string> MSG = new Dictionary<string, string>(); MSG.Add("AAAAA", "CCCCC"); MSG.Add("BBBBB", "DDDDD"); TransfEvent(MSG);//传输到委托事件 } private void Wdata_FormClosing(object sender, FormClosingEventArgs e) { MessageBox.Show("11111111111111"); } } }namespace winlogin//主窗口 { public partial class AddData : CCSkinMain { public AddData(string msg) { InitializeComponent(); } private void button2_Click(object sender, System.EventArgs e) { Wdata wd = new Wdata(); wd.TransfEvent += frm_TransfEvent;//加入委托事件 wd.ShowDialog(); } void frm_TransfEvent(Dictionary<string, string> value)//读数和显示 { textBox2.Text = value["BBBBB"].ToString(); textBox3.Text = value["AAAAA"].ToString(); } } }
相关推荐
-
C# 任意类型转换成json (datable,list,array 等) csharp
2019-1-7
-
.net core多层架构增删改查简单封装 csharp
2019-1-8
-
多线程任务扩展类 csharp
2019-1-7
-
C#多线程编程 csharp
2019-1-8
-
WindowForm窗体去掉边框后每个控件的通用移动事件 csharp
2019-1-7
-
c#观察者模式 csharp
2019-1-8
-
C#去除字符串空格 csharp
2019-1-8
-
通用验证类 csharp
2019-1-7
-
C#生成Code39(extend)条形码 csharp
2019-1-8
-
ini配置文件操作类 csharp
2019-1-7