Delete a specific line in a .NET RichTextBox

后端 未结 9 1522
后悔当初
后悔当初 2021-01-19 15:08

How can I delete a specific line of text in a RichTextBox ?

9条回答
  •  后悔当初
    2021-01-19 15:46

    Based on tomanu's solution but without overhead

    int start_index = LogBox.GetFirstCharIndexFromLine(linescount);
    int count = LogBox.GetFirstCharIndexFromLine(linescount + 1) - start_index;
    LogBox.Text = LogBox.Text.Remove(start_index, count);
    

    note that my linescount here is linescount - 2.

提交回复
热议问题