如何在其他文本框中写相同的文本? [英] how to write same text in other text box?

查看:54
本文介绍了如何在其他文本框中写相同的文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有2个文本框.

正如我在键入master时所看到的那样,一旦我在一个文本框中编写了内容,就应将其显示在另一个文本框中.
这将如何发生?应该在第一个文本框的哪个事件上编写代码.

我没有发现任何此类事件.

Hi,

I have 2 textboxes.

As soon as I write something in one textbox, it should be displayed on the other textbox, as we see in typing master.

How would this happen and on which event of the first textbox the code should be written.

I didn''t find any such event.

推荐答案

假设您正在谈论Winforms应用程序(因为您认为不合适,无法指定):

处理用户在其中键入内容的框的TextChanged事件,在该事件处理程序中,只需将键入的TextBox的内容分配给另一个TextBox.
Assuming you''re talking about a Winforms app (since you didn''t see fit to specify):

Handle the TextChanged event for the box in which the user is typing, and in that event handler just assign the contents of the typed-in TextBox to the other TextBox.


在asp.net

textbox1应该像这样

in asp.net

textbox1 should be like this

<asp:TextBox ID="txtbox1" runat="server" OnTextChanged="txtbox1_TextChanged"
                                                                            AutoPostBack="true" />





<asp:textbox id="txtbox2" runat="server" xmlns:asp="#unknown" />




//在像这样的文本更改事件中将文本框1中的值分配给textbox2




//assign value in textbox 1 to textbox2 in text changed event like this

 protected void txtbox1_TextChanged(object sender, EventArgs e)
{
txtbox2.Text=txtbox1.Text;
}


这篇关于如何在其他文本框中写相同的文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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