在RichTextBox中添加水平可调整大小的条

时间:2019-11-19 05:50:16

标签: c# richtextbox

我需要在我的RichTextBox中添加一条水平线,{#3}}在#3起作用。神奇的是,这条线可以延长更长的时间,但仍保持厚度,这是我的要求。唯一的问题是,水平线在Word2016中变成了“浅蓝色”,而不是我期望的黑色。我至少在眼睛上更喜欢纯黑色。我创建了一条像素宽度的线并插入到我的RichTextBox中,但是当我水平调整大小时,该线变粗了。我的问题是,为什么this code在第3名时发挥如此神奇的作用以保持厚度?

private void AppendHorizontalBar(RichTextBox rtb) 
    {
        //https://stackoverflow.com/questions/8324801/richtextbox-draw-an-rtf-line
        // This is the RTF section to add.
        string horizontalBarRtf = @"{\pict\wmetafile8\picw12777\pich117\picwgoal7245\pichgoal60 0100090000035b00000004000800000000000400000003010800050000000b0200000000050000000c022100280e030000001e0008000000fa0200000300000000008000040000002d01000007000000fc020100000000000000040000002d010100080000002503020011001100170e110008000000fa0200000000000000000000040000002d01020007000000fc020000ffffff000000040000002d01030004000000f0010000040000002701ffff030000000000}";

        string alignSetting = "\\pard\\ql\\fs20\\lang1033"; // set this to empty string to keep left text alignment            
        // Wrap to-add RTF section in RTF tag with a line breaker            
        string strSelectedRtf = String.Format("{{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033\\uc1 {0} {1}}}", alignSetting, horizontalBarRtf); //take off line breaker           
        rtb.SelectedRtf = strSelectedRtf;
    }

this line

0 个答案:

没有答案