[英]Add multiple rows of text to a text box with different buttons c#
I have built an interface full of buttons (47) and each of them have an address.我构建了一个充满按钮的界面(47 个),每个按钮都有一个地址。 When you click the button, it's supposed to put the address in the text box.当您单击按钮时,它应该将地址放入文本框中。 I can do this, but only with one address at a time.我可以这样做,但一次只能使用一个地址。 When I push a different button the previous address gets copied over by the new one.当我按下一个不同的按钮时,以前的地址会被新的地址复制过来。
The code behind the buttons are simple:按钮背后的代码很简单:
protected void btnYmca_Click(object sender, EventArgs e)
{
txtOut.Text = "Some address here\n";
}
All of these buttons are set up like this.所有这些按钮都是这样设置的。 There is nothing in these buttons to clear the text, but it does automatically when I click a different button.这些按钮中没有任何内容可以清除文本,但是当我单击不同的按钮时它会自动清除。 The text box is set to MultiLine.文本框设置为 MultiLine。
Is there a way to make the text line stay in the text box when you hit one button, then add a new address on a line below it?当您点击一个按钮时,有没有办法让文本行留在文本框中,然后在它下面的一行中添加一个新地址? I have a separate button to clear the text box when finished.我有一个单独的按钮来完成后清除文本框。
You need to add a +
before the =
.您需要在=
之前添加一个+
。 This will then append the value instead of overwriting it.然后,这将附加该值而不是覆盖它。
protected void btnYmca_Click(object sender, EventArgs e)
{
txtOut.Text += "Some address here\n";
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.