如何获取RTF值(非纯文本值)

时间:2014-02-16 09:35:34

标签: c# winforms rtf txtextcontrol

我正在使用TX TextEditingControl (免费版),我认为这绝对是好的。

但我似乎无法获得我需要的RTF(文本)内容。

//Define
private TXTextControl.TextControl rtf = new  TXTextControl.TextControl();


 [...code...]

    private void button_Click(object sender, EventArgs e) {..


   //rtf.Save(s, TXTextControl.StreamType.RichTextFormat);
   //This is what I would like to do but I cant find the property or function that does this.
   string s = rtf.DocumentRTF;

   //Im expecting the standard RTF Format but I get blank
   MessageBox.Show(s);

}

2 个答案:

答案 0 :(得分:0)

发现它!没有RTF属性,要获得输出必须使用save()函数。幸运的是,你可以写入流和字符串。

       string s = "";

        rtf.Selection.Bold = true;

        //rtf.Selection.Save(TXTextControl.StreamType.RichTextFormat);

        rtf.Save(out s,TXTextControl.StringStreamType.RichTextFormat);

        MessageBox.Show(s);

答案 1 :(得分:0)

亲爱的使用以下

for Vb.Net

        Dim RegFont As New Font("Arial", UseFontSize, FontStyle.Bold)
        Dim VIPFont As New Font("Arial", UseFontSize, FontStyle.Bold)
        MyRitchText.SelectionFont = VIPFont
        MyRitchText.SelectionAlignment = HorizontalAlignment.Center
        MyRitchText.SelectionColor = Color.Green

表示c#

        Font RegFont = new Font("Arial", UseFontSize, FontStyle.Bold);
        Font VIPFont = new Font("Arial", UseFontSize, FontStyle.Bold);
        MyRitchText.SelectionFont = VIPFont;
        MyRitchText.SelectionAlignment = HorizontalAlignment.Center;
        MyRitchText.SelectionColor = Color.Green;

谢谢:D