如何在不删除旧数据的情况下将数据添加到文本框中。 [英] how to add data to a textbox without deleting the old data.

查看:142
本文介绍了如何在不删除旧数据的情况下将数据添加到文本框中。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

private void button1_Click(object sender, EventArgs e)
        {
            string a = textBox1.Text;
            textBox2.Text = a;
            textBox1.Clear();
        }



这是我尝试的但是这里的问题是当在textbox1中输入新数据时它会写入textbox2但是之前的数据被省略。 .....我希望程序添加下一个数据,但不要删除以前的数据请帮助............









问候,

Ahsan Naveed


this is what i tried but the problem here is that when new data is entered in textbox1 it is written in textbox2 but the previous data is omitted......I want the program to add the next data but do not delete the previous data please help............




Regards,
Ahsan Naveed

推荐答案

我知道这个问题已经得到了充分的回答,但我想指出还有另外一种方法:

I know this question has already been sufficiently answered, but I'd like to point out that there is another way:
textBox1.AppendText("SomeString");





如果您的文本框包含大量文本(例如显示正在发生的日志条目),这种方式会更有效。它还有自动滚动到最后新添加文本的奖励。



This way is much more efficient if your textbox contains large amounts of text (such as displaying log entries as they're happening. It also has the bonus of automatically scrolling to the end newly added text.


尝试:

Try:
string a = textBox1.Text;
textBox2.Text += a;
textBox1.Clear();


尝试

Try
textBox1.Text = "textbox1";
textBox2.Text = "textbox2";
textBox2.SelectionStart = 3;
textBox2.SelectedText = textBox1.Text;


这篇关于如何在不删除旧数据的情况下将数据添加到文本框中。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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