如题,我做的中间做了十几个窗体,还在两个文件下,应该和三个窗体差不多,想知道如何实现,最好有例子。谢谢了
http://bbs.csdn.net/topics/360140208
没人呢。。。。。。。。
定义一个static的中间类,第三个窗体更改static类的属性值,static类属性值更改引发第一个窗体的text更改(委托,事件),搞定收工
把第一个窗体控件设为public,就可以直接通过窗口1的对象直接改了
将多个窗体的实例存在在一个公共类中,这样每个窗口可通过该公共类访问其他窗体的实例。当然其他窗口上的控件访问权限也要设置为public的。
c#winform间传值 http://m.blog.csdn.net/article/details?id=49073965
c#winform间传值 http://m.blog.csdn.net/article/details?id=49073965
你定义一个static变量保存第一个窗体的控件,在哪里都可以随便修改了
窗口间传值的问题直接用委托,原理很简单,可能你需要认真看下,在第一个窗体建立一个方法控制窗体一控件的方法,然后使用委托在窗体三中执行此方法
private void button1_Click(object sender, EventArgs e)
{
Form2 frm2 = new Form2(ShowMsg);
frm2.Show();
}
void ShowMsg(string str)
{
label1.Text = str;
}
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 窗体传值
{
//声明一个委托
public delegate void DelTest(string str);
public partial class Form2 : Form
{
public DelTest _del;
public Form2(DelTest del)
{
this._del = del;
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
_del(textBox1.Text);
}
}
}