WPF 子窗体访问父窗体的函数
来源:互联网 发布:宜搜软件下载 编辑:程序博客网 时间:2024/05/20 03:44
http://www.silverlightchina.net/html/study/WPF/2011/0706/8827.html
子窗体代码 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace WindowsApplication1{ //定义委托 public delegate void ChangeTextHandler( string
子窗体代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1 {
//定义委托
public delegate void ChangeTextHandler(string text);
public partial class ChildFrm : Form {
//定义事件
public event ChangeTextHandler ChangeTextEvent;
public ChildFrm() {
InitializeComponent();
}
/// <summary>
///
/// </summary>
/// <param name="sender">事件源</param>
/// <param name="e">事件对象</param>
private void radioButton1_CheckedChanged(object sender, EventArgs e) {
RadioButton rdo = sender as RadioButton;
//引发事件
if (ChangeTextEvent != null) {
ChangeTextEvent(rdo.Text);
}
}
private void ChildFrm_MouseClick(object sender, MouseEventArgs e) {
//e.Button == MouseButtons.Right
}
private void ChildFrm_Load(object sender, EventArgs e)
{
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1 {
//定义委托
public delegate void ChangeTextHandler(string text);
public partial class ChildFrm : Form {
//定义事件
public event ChangeTextHandler ChangeTextEvent;
public ChildFrm() {
InitializeComponent();
}
/// <summary>
///
/// </summary>
/// <param name="sender">事件源</param>
/// <param name="e">事件对象</param>
private void radioButton1_CheckedChanged(object sender, EventArgs e) {
RadioButton rdo = sender as RadioButton;
//引发事件
if (ChangeTextEvent != null) {
ChangeTextEvent(rdo.Text);
}
}
private void ChildFrm_MouseClick(object sender, MouseEventArgs e) {
//e.Button == MouseButtons.Right
}
private void ChildFrm_Load(object sender, EventArgs e)
{
}
}
}
父窗体代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1 {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e) {
ChildFrm frm = new ChildFrm();
//订阅事件
frm.ChangeTextEvent += new ChangeTextHandler(frm_ChangeTextEvent);
frm.ShowDialog();
}
void frm_ChangeTextEvent(string text) {
this.textBox1.Text = text;
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1 {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e) {
ChildFrm frm = new ChildFrm();
//订阅事件
frm.ChangeTextEvent += new ChangeTextHandler(frm_ChangeTextEvent);
frm.ShowDialog();
}
void frm_ChangeTextEvent(string text) {
this.textBox1.Text = text;
}
}
}
本文来自姚蔚的博客,原文地址:http://hi.baidu.com/lilipangtou/blog/item/92e091f89cb6153b4f4aeabd.html
0 0
- WPF 子窗体访问父窗体的函数
- 子窗体访问父窗体的变量
- wpf 子窗体和父窗体的通信
- 子窗体访问父窗体控件
- parent.myFrame.cols ff 子窗体取得(访问)父窗体中另一子窗体的ID
- 打开左侧导航栏,子窗体取得(访问)父窗体中另一子窗体的ID
- js子窗体调用父窗体函数的问题
- Web所有父窗体与子窗体的交互方法列举(子调用父窗体函数)
- Web所有父窗体与子窗体的交互方法列举(子调用父窗体函数)
- Web所有父窗体与子窗体的交互方法列举(子调用父窗体函数)
- 子窗体、父窗体
- WPF 如何访问其他窗体的控件
- WPF获取子、父窗体控件
- c# winform 子窗体更新父窗体,调用父窗体的函数
- WPF窗体 WPF窗体调用函数
- 子窗体如何传值到父窗体并调用父窗体的函数
- 子窗体与父窗体的通讯
- C#----子窗体调用子窗体,但调用的子窗体仍属于父窗体
- Android学习笔记第六章
- Libnids开发包介绍
- NSCFArray insertObject:atIndex:]: mutating method sent to immutable obje的解决方法
- ScheduledExecutorService的使用
- Wi-Fi对决蓝牙4.0:一场无硝烟战争
- WPF 子窗体访问父窗体的函数
- 【Android开源框架列表】
- flex的页面跳转问题
- 字符编码笔记:ASCII,Unicode和UTF-8
- Sqrt(x) 根号下x
- Obeverser观察者模式
- Hadoop集群(第4期)_SecureCRT使用
- 给Tomcat,Apache配置gzip压缩(HTTP压缩)功能 (转)
- js 中导出excel 较长数字串会变为科学计数法