如何在表单C#之间更新数据 [英] How Do I Update Data Between Forms C#

查看:93
本文介绍了如何在表单C#之间更新数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序中有两个Win表单。



i使用以下代码将文本值从textBox传递到textbox表单之间。





cOde in form1

i have two Win Forms in my application.

i used following code to pass text value from textBox to textbox Between forms.


cOde In form1

private void button2_Click(object sender, EventArgs e)
        {
string value = textBox4.Text;
            contactpro f = new contactpro(value);
            f.Show();
}





表格2代码





code in form2

public contactpro(string value)
        {
            InitializeComponent();
             textBox1.Text = value;
        }







此代码适用于传递数据但在Form2中的textBox1中的值(contactpro)总是保持不变。



i希望更新值,因为我在Form1中的textBox4中输入任何内容。




this code works well for passing data but the value in textBox1 in Form2(contactpro) remains same always.

i want the value to be updated as i type anything in textBox4 in Form1.

推荐答案

好吧,它比这复杂一点 - 但是一旦你了解它就不多了:在两个表格之间传递信息,第2部分:孩子到父母 [ ^ ]
OK, it's a little more complex than that - but not much once you get your head around it: Transferring information between two forms, Part 2: Child to Parent[^]


这篇关于如何在表单C#之间更新数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆