简体   繁体   English

我如何在 Visual Studio C# 中的 TextBox 中获取值,而不删除 TextBox 上已有的信息

[英]How do i get values into a TextBox in Visual studio C# without the information already on the TextBox gets erased

textBox1.Text = "4 Nuggets"; textBox1.Text = "4 个掘金"; If i wanted to press that again it wont put it as a list instead it will replace it.如果我想再次按下它,它不会把它作为一个列表,而是会替换它。 How do i fix this?我该如何解决?

If you want to write like a list first you should make your textbox multiline.如果你想先像列表一样写,你应该让你的文本框多行。 You may make it from the designer or with code at runtime.您可以通过设计器或在运行时使用代码来实现。 Just wrote make textbox multiline to the inte.net if you did not.如果没有,请将 make textbox multiline 写到 inte.net。

So if you have a textBox like this所以如果你有一个像这样的文本框

=>4 Nuggets => 4个掘金

and you want to add another line like你想添加另一行

=>4 Nugget => 4块

=>2 Chicken =>2鸡

as like in the comments you should use +=, but to pass the next line you should use '\n'就像在注释中一样,您应该使用 +=,但要传递下一行,您应该使用 '\n'

So your code must be something like this.所以你的代码必须是这样的。

    string newLine = //something;
    textBox1.Text += "'\n'" + newLine;

Or或者

     string newLine = //something;
     textBox1.Text = textBox1.Text + "'\n'" + 
     newLine;

If you need further assistance just wrote如果您需要进一步的帮助,请写信

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 Visual Studio C# 中制作一个将特定文本插入文本框中的按钮? - How do i make a button that inserts A Certain text into a textbox in Visual Studio C#? 如何使用OleDb将Visual Studio c#中MS-Access的值插入到textBox中? - how do I insert into a textBox a value from MS-Access in visual studio c# using OleDb? 如何获取输入到 TextBox 中的信息? - How do I get the information typed into a TextBox? 获取另一个TextBox值的TextBox VISUAL C# - TextBox that Gets the value of another TextBox VISUAL C# C#,如何验证wpf文本框值? - C#, How do I validate wpf textbox values? 如何在 C# 中存储文本框中的值 - How do I store values from textbox in C# C# 是否可以在不覆盖文本框的第一个输入值的情况下在一个文本框中获取两个输入文本框值? - C# Is it possible to get the two input textbox values in one textbox without overwriting the first input value of textbox? 我如何从 C# 中的字符串文本框获取值 - How do i get value from string textBox in C# 如何在文本框中显示从串行端口接收的数据而文本不会在Visual Studio C#中消失? - How to display data received from serial port in a textbox without the text disappearing in Visual Studio C#? C#Visual Studio文本框转换为文本文件 - c# visual studio textbox into textfile
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM