0

我正在尝试将 RichTextBox 的整个文本复制到剪贴板。

这就是我在 RichTextbox 中附加文本的方式:

RichTextBox1.Text += vbNewLine & AlbumName
RichTextBox1.Text += vbNewLine & AlbumLink & vbNewLine
RichTextBox1.SelectionStart = RichTextBox1.Text.Length
RichTextBox1.ScrollToCaret()

但我无法识别 vbnewline(也尝试使用 VBCrlf):

Private Sub ToolStripMenuItem2_Click(sender As Object, e As EventArgs) Handles ToolStripMenuItem2.Click
    Clipboard.SetText(RichTextBox1.Text.Replace(vbNewLine, "              "))
End Sub

当我粘贴文本时,记事本无法识别该空白行,但如果我将相同的复制文本粘贴到其他 TextEditor 中,例如在“ SublimeText Editor ”中,则 VBNewLines 被识别...

更新

尝试使用 Environment.NewLine 但我得到了相同的结果。

这是从我的富文本框中复制并粘贴到记事本中的示例文本:

Escape the Fate - Ungrateful (2013)http://vk.com/doc3197020_179614905?hash=97855f387cf7d8a85bThe King Is Dead - Once Upon A Burning House [EP] (2013)http://vk.com/doc3197020_183005958?hash=bdea3f04fe101eae11Sleeping With Sirens - Alone [single] (2013)http://vk.com/doc3197020_182922598?hash=27e50a03a30b4ec89cPalisades - Outcasts (2013)http://vk.com/doc3197020_182588309?hash=90f629956bcfc59029Done!

这是粘贴在其他编辑器中的相同文本:

Escape the Fate - Ungrateful (2013)
http://vk.com/doc3197020_179614905?hash=97855f387cf7d8a85b

The King Is Dead - Once Upon A Burning House [EP] (2013)
http://vk.com/doc3197020_183005958?hash=bdea3f04fe101eae11

Sleeping With Sirens - Alone [single] (2013)
http://vk.com/doc3197020_182922598?hash=27e50a03a30b4ec89c

Palisades - Outcasts (2013)
http://vk.com/doc3197020_182588309?hash=90f629956bcfc59029

Done!
4

1 回答 1

3

你可以使用:

Private Sub ToolStripMenuItem2_Click(sender As Object, e As EventArgs) Handles ToolStripMenuItem2.Click
    Dim curStart As Integer = RichTextBox1.SelectionStart
    Dim curLength As Integer = RichTextBox1.SelectionLength

    RichTextBox1.SelectAll()
    RichTextBox1.Copy()

    RichTextBox1.Select(curStart, curLength)
    RichTextBox1.Focus()
End Sub
于 2013-05-20T15:49:21.690 回答