各位:
    本人乃新手,遇到了一个问题。我想在一个Richtextbox中显示超链接,但好象richtextbox中只能探测到www.xxx.xxx类型的文本当作正确的超链。而我想象网页中那样显示一些友好的名字人作为超链,如here作为一个超链。
    如何实现,请指点一二,谢谢!

解决方案 »

  1.   

    这需要去查rft格式的文档,当你需要插入一个link时自己向richTextBox里加入url的标签。rtf格式我也不太懂,楼下继续…………
      

  2.   

    <a href='http://www.csdn.net'>here</a>
      

  3.   

    不行的,我是从一个txt文件中读入内容,如<a href="">here</a>,但在richTextBox中会原样输出,而不是显示超链。
      

  4.   

    如果smilnet的格式是正确的话,可以这样在当前插入点插入一个link:

    public static void InsertURL(RichTextBox rtb, string name,string url)
    {
    StringBuilder _rtf = new StringBuilder();
    _rtf.Append("<a href='"+url+"'>");
    _rtf.Append(name);
    _rtf.Append("</a>");
    rtb.SelectedRtf = _rtf.ToString();
    }

    使用:
    InsertURL(this.richTxtBox,"here","http://www.csdn.net");
      

  5.   

    不要用RichTextBox.Append(string str)那个函数
    因为那是将str按照文本格式写入rtf文档。那样会自动添加许多其他的标签。
      

  6.   

    我查了一下,smilnet的格式好像不对,下面是RTF文档里面的信息LZ可以参考:注意其中的hlinkbase一项
    Document Area
    Once the RTF header is defined, the RTF reader has enough information to correctly read the actual document text. The document area has the following syntax:
    <document> <info>? <docfmt>* <section>+
    Information Group
    The \info control word introduces the information group, which contains information about the document. This can include the title, author, keywords, comments, and other information specific to the file. This information is for use by a document-management utility, if available.
    The information group has the following syntax:
    <info> '{' <title>? & <subject>? & <author>? & <manager>? & <company>? <operator>? & <category>? & <keywords>? & <comment>? & \version? & <doccomm>? & \vern? & <creatim>? & <revtim>? & <printim>? & <buptim>? & \edmins? & \nofpages? & \nofwords? \nofchars? & \id? '}'
    <title> '{' \title #PCDATA '}'
    <subject> '{' \subject #PCDATA '}'
    <author> '{' \author #PCDATA '}'
    <manager> {' \manager #PCDATA '}'
    <company> {' \company #PCDATA '}'
    <operator> '{' \operator #PCDATA '}'
    <category> {' \category #PCDATA '}'
    <keywords> '{' \keywords #PCDATA '}'
    <comment> '{' \comment #PCDATA '}'
    <doccomm> '{' \doccomm #PCDATA '}'
    <hlinkbase> '{' \hlinkbase #PCDATA '}'
    <creatim> '{' \creatim <time> '}'
    <revtim> '{' \revtim <time> '}'
    <printim> '{' \printim <time> '}'
    <buptim> '{' \buptim <time> '}'
    <time> \yr? \mo? \dy? \hr? \min? \sec?Some applications, such as Word, ask the user to type this information when saving the document in its native format. If the document is then saved as an RTF file or translated into RTF, the RTF writer specifies this information using control words in the following table. These control words are destinations, and both the control words and the text should be enclosed in braces ({ }).
    Control word Meaning
    \title Title of the document. This is a destination control word.
    \subject Subject of the document. This is a destination control word.
    \author Author of the document. This is a destination control word.
    \manager Manager of the author. This is a destination control word.
    \company Company of the author. This is a destination control word.
    \operator Person who last made changes to the document. This is a destination control word.
    \category Category of the document. This is a destination control word.
    \keywords Selected keywords for the document. This is a destination control word.
    \comment Comments; text is ignored. This is a destination control word.
    \versionN Version number of the document.
    \doccomm Comments displayed in the Summary Info or Properties dialog box in Word. This is a destination control word.
    \hlinkbase The base address that is used for the path of all relative hyperlinks inserted in the document. This can be a path or an Internet address (URL). 
      

  7.   

    谢谢各位,尤其是JadyWang,我先试一下。