如何将句子从一个文本框复制到另一个文本框 [英] how to copy sentences from one text box to another text box

查看:75
本文介绍了如何将句子从一个文本框复制到另一个文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一个文本框,我将文字文件转换为文本文件,还从新行中分离了这些句子(意味着文本框中的所有句子均从新行开始)
现在,我想将第一个句子从第一个文本框发送到第二个文本框.

Hi,
i have one text box where i convert word file to text file and also i separated these sentences from a new line(means all sentences in text box starts from a new line)
now i want to send first sentence from first text box to second text box.

推荐答案

如果您使用换行符,那么您的文本框可能设置为多行:
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[^]


这篇关于如何将句子从一个文本框复制到另一个文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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