一佳一

记录像1+1一样简洁的代码
随笔 - 396, 文章 - 0, 评论 - 95, 阅读 - 107万

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

wpf richtextbox 插入新添加内容添加到头部

Posted on   一佳一  阅读(555)  评论(0编辑  收藏  举报
复制代码
public void AppendTextToHead(string text)
        {
            TextRange textRange = new TextRange(txtRich.Document.ContentStart, txtRich.Document.ContentEnd);
            //把之前的文本追加到新内容后面
            string value = text + "\r" + textRange.Text;
            Paragraph p = new Paragraph();
            p.Inlines.Add(new Run(value));
            txtRich.Document.Blocks.Clear();
            txtRich.Document.Blocks.Add(p);
        }
复制代码

代码如上,其他语言也可以用这个逻辑,比如Web的 

 $("#opinfo").html(szTip + $("#opinfo").html());

 

相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)
点击右上角即可分享
微信分享提示