【问题标题】:How to prevent Richtextbox Table column width adjustment mess up text inside table?如何防止 Richtextbox 表格列宽调整弄乱表格内的文字?
【发布时间】:2020-09-27 16:32:42
【问题描述】:

我正在制作 Richtextbox (rtb),显示来自 .rtf 文件的文本、表格和图像(rtf 文件加载)

if (openFileDialog.ShowDialog() == true)
        {
            string directoryPath = System.IO.Path.GetDirectoryName(openFileDialog.FileName);

            TextRange range;
            FileStream fStream;
            range = new TextRange(RichTextControlLeft.Document.ContentStart, RichTextControlLeft.Document.ContentEnd);
            fStream = new FileStream(openFileDialog.FileName, FileMode.OpenOrCreate);
            range.Load(fStream, DataFormats.Rtf);
            fStream.Close();
        }

我目前在调整表格以适应我的 rtb 时遇到问题,因为导入的表格显示在我的 rtb 之外

这里是主要问题,在右边,表格没有完全显示

然后我试图用这个来调整表格列宽

                foreach (var item in table.Columns)
                {
                    item.Width = GridLength.Auto;
                }

导致文本出现奇怪行为的代码

这个问题有什么解决办法吗?谢谢

【问题讨论】:

    标签: c# wpf richtextbox code-behind flowdocument


    【解决方案1】:

    原来,客户端的rtf格式的表格有问题 重绘表格,解决问题

    【讨论】:

      猜你喜欢
      • 2015-04-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-11
      • 2010-10-22
      • 2021-02-10
      • 2011-02-01
      • 2021-12-16
      相关资源
      最近更新 更多