小编use*_*565的帖子

删除富文本框的最后一行?

我喜欢删除以 ; 结尾的 richtextbox 的最后一行。半柱。我喜欢删除这一行,直到;最后一个半列之前的半列。

例子:

hello do not delete this line;
hello this sentence will continue...
untill here;
Run Code Online (Sandbox Code Playgroud)

结果应该是:

hello do not delete this line;
Run Code Online (Sandbox Code Playgroud)

我的代码:

private void button1_Click_1(object sender, EventArgs e) {
        List<string> myList = richTextBox1.Lines.ToList();
        if (myList.Count > 0) {
            myList.RemoveAt(myList.Count - 1);
            richTextBox1.Lines = myList.ToArray();
            richTextBox1.Refresh();
        }
    }
Run Code Online (Sandbox Code Playgroud)

c# regex stringbuilder substring

0
推荐指数
1
解决办法
7795
查看次数

标签 统计

c# ×1

regex ×1

stringbuilder ×1

substring ×1