【问题标题】:How can I insert a table in a RichTextBox at a specific location如何在特定位置的 RichTextBox 中插入表格
【发布时间】:2018-10-14 13:47:50
【问题描述】:

在我的 Richtextbox 中,我有一些文本。文本中间是字符串 [tabe=用户]

如何用我的表格替换(ob Buttonpress)字符串

我创建了一个创建表格的方法

public static Table CreateTable(DataTable dataTable) {
    Table table = new Table();
    //convert DataTable to Table (with foreach) for RichTextbox //works fine
    return table;
}

//insert in the Bottom of the TextBox
RichTextBoxItem.Document.Blocks.Add(CreateTable(myDataTable));

我知道,它可以添加到段落,但它不存在特定段落

谢谢

【问题讨论】:

    标签: c# wpf replace datatable richtextbox


    【解决方案1】:

    我的解决方案:

    RichTextBox theTable = new RichTextBox();
    theTable.Document.Blocks.Add(CreateTable(thisDepTable));
    byte[] theRichTable = GetRichContent(theTable);
    

    首先创建一个新的 RichTextBox 并附加表格。然后我从 RichTextBox 中读取内容作为字节码。字节码可以从我的 MainRichTextBox 的字节码中附加到正确的位置作为替换。

    如果有更好的方法,我很感兴趣

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-08-15
      • 1970-01-01
      • 2021-04-23
      • 1970-01-01
      • 1970-01-01
      • 2021-12-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多