如何在表单2的文本框中显示form1的输入? [英] How can an input of form1 can be displayed on the textbox of form 2?

查看:67
本文介绍了如何在表单2的文本框中显示form1的输入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以在form2的textbox1上自动写入或生成form1的textbox1的输入。请帮忙..谢谢..



我尝试过:



我不知道这个..我搜索很多..但我没有一个提示..请帮助..

解决方案

不自动,不 - 但是自己做起来并不难。

这两种形式之间的关系很重要:假设Form1创建了Form2的实例,那么基本上有两种方式:

1)创建一个Form2构造函数,它接受一个字符串参数并在创建实例时传递文本框内容 - 这会将其设置一次,并且不会再次更改它,并且可以与Show或ShowDialog一起使用。

2)在Form2中创建一个属性,让Form1从它创建的实例中设置它。这允许您在Form1中更改Form2中的值,并且只在Show中使用,而不是ShowDialog。

如果不是这样,那么看看这些: br />
在两个表格之间传递信息,第1部分:家长到孩子 [ ^ ]

在两个表单之间传输信息,第2部分:孩子到父母 [ ^ ]

在两种表格之间传递信息,第3部分:儿童到儿童d [ ^ ]

它们都包含在实践中显示它的示例代码。






有很多方法可以将值从一个页面传递到另一个页面。

1.查询字符串

2.从源页面发布信息

3.会话状态



参考文献:



如何:在ASP.NET Web窗体页面之间传递值 [ ^ ]



BinaryIntellect知识库.Net& Web开发 - 在ASP.NET Web窗体之间传递值 [ ^ ]



代码:将数据从一个Web窗体页传递到另一个(Visual C#) [ ^ ]



谢谢,

Can the input of textbox1 of form1 can be automatically written or generated on the textbox1 of form2.? Please help.. Thank you..

What I have tried:

I have no idea about this.. I search alot.. but i didn't got a single hint.. please help..

解决方案

Not automatically, no - but it's not difficult to do yourself.
The "relationship" between the two forms is important here: assuming the Form1 creates the instance of Form2 then there are basically two ways:
1) Create a Form2 constructor that takes a string parameter and pass the textbox content when you create the instance - this sets it once, and doesn't change it again, and can be used with Show or ShowDialog.
2) Create a property in Form2 and have Form1 set it from the instance it creates. This allows you to change the value in Form2 when it changes in Form1, and only really works with Show, not with ShowDialog.
If that isn't the case, then have a look at these:
Transferring information between two forms, Part 1: Parent to Child[^]
Transferring information between two forms, Part 2: Child to Parent[^]
Transferring information between two forms, Part 3: Child to Child[^]
They all contain example code which shows it in practice.


Hi,

There are lots of ways to pass values from one page to other.
1. Query String
2. Post Information from Source Page
3. Session State

References:

How to: Pass Values Between ASP.NET Web Forms Pages[^]

BinaryIntellect Knowledge Base | .Net & Web Development - Passing Values between ASP.NET Web Forms[^]

Code: Passing Data from One Web Forms Page to Another (Visual C#)[^]

Thanks,


这篇关于如何在表单2的文本框中显示form1的输入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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