使用RTF格式拷贝之后,会自动在文本最后面添加“\r\n”,所以只能通过代码将其删除:
- private void Button_Click(object sender, RoutedEventArgs e)
- {
- //byte[] bytes;
- //textControl1.Save(out bytes, BinaryStreamType.InternalFormat);
- //textControl2.Load(bytes, BinaryStreamType.InternalFormat);
- string str;
- textControl1.Save(out str, StringStreamType.RichTextFormat);
- textControl2.Load(str, StringStreamType.RichTextFormat);
- textControl2.Selection.Start = textControl1.Text.Length;
- textControl2.Selection.Length = 2;
- textControl2.Selection.Text = "";
- }
复制代码 |