【发布时间】:2023-03-17 00:23:02
【问题描述】:
我需要将一些 rtf 文本从数据网格粘贴到流文档中。我想将它粘贴到富文本框中的插入符号位置。除非我有项目符号或编号列表,否则此方法有效。它将粘贴在项目符号或数字之前。
我到处寻找这个没有运气。
private void dgStandardText_MouseDoubleClick(object sender, MouseButtonEventArgs e) {
if (dgStandardText.SelectedItems.Count > 0) {
foreach(DataRowView row in dgStandardText.SelectedItems) {
byte[] byteArray = Encoding.ASCII.GetBytes(row[3].ToString());
using(MemoryStream ms = new MemoryStream(byteArray)) {
TextRange tr = new TextRange(txtAreaText.CaretPosition, txtAreaText.CaretPosition);
tr.Load(ms, DataFormats.Rtf);
}
}
}
NeedSave = true;
dgStandardText.SelectedItems.Clear();
}
【问题讨论】:
标签: c# wpf richtextbox flowdocument