需要帮助阅读下一行 [英] Need help to read next line
问题描述
您好我正在使用stringreader从richtextbox中读取数据字符串。数据正被添加到richtextbox中,我需要在添加到标签时显示新添加的行,以便在将新行添加到richtextbox时标签将更改。类似于读取结束的流程读取器。
请帮助我不确定在这种情况下使用什么循环
提前谢谢
这是我尝试过但由于某种原因我只获得了第一个添加的条目。下一个添加的条目未显示在标签中
Hello I am using stringreader to read strings of data from a richtextbox. Data is being added to the richtextbox and I need to show the new added line when its added to a label so that the label will change when a new line is added to the richtextbox. something like read to end for streamreader.
please help I am unsure what loop to use in this case
thank you in advance
Here is what i have tried but for some reason i only get the first added entry. the next added entry does not show in the label
Dim reader As New StringReader(RichTextBox2.Text)
Dim tmp As String = reader.ReadToEnd
Dim MD As Match = md.Match(tmp)
For Each M As String In RichTextBox2.Lines
If M.Contains(MD.ToString) Then
Label4.Text = MD.ToString
End If
Next M
推荐答案
当您获得RichTextBox2.Lines中的所有行时。
要添加最后一行,为什么不使用。
string str = RichTextBox2.Lines [RichTextBox2.Lines.Length - 1];
When you get all lines in RichTextBox2.Lines.
To get the last line added why don't you use.
string str = RichTextBox2.Lines[RichTextBox2.Lines.Length - 1];
这篇关于需要帮助阅读下一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!