且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将句子从一个文本框复制到另一个文本框

更新时间:2023-11-27 18:36:46

如果您使用换行符,那么您的文本框可能设置为多行:
If you have used a newline, then presumably your text box is set as multiline:
TextBox2.Text = TextBox1.Lines[0];


将在Environment.NewLine上Textbox1的内容,然后
将结果字符串[]中的第一项分配给Textbox2.
Split the content of Textbox1 on Environment.NewLine and then
assign the first item in the resulting string[] to Textbox2.
string[] textbox1SplitValues = Textbox1.Text.Split(Environment.NewLine);
if( textbox1SplitValues.Length > 0 )
{
   Textbox2.Text = textbox1SplitValues[0];
}



根据您昨天的问题(如何 [ TextBoxBase.Lines属性 [



Based on your question yesterday (how to break a text file into line by line sentences.[^]) I am assuming that this is a continuation of that process, and there is a better way to do that first step if you want to achieve a good result on this step. Instead of simply applying the results of your initial split from the word doc text to Textbox1.Text, use the Textbox1.Lines property instead. TextBoxBase.Lines Property[^]