Links inside rich textbox?

后端 未结 4 1675
夕颜
夕颜 2021-01-01 11:20

I know that richtextboxes can detect links (like http://www.yahoo.com) but is there a way for me to add links to it that looks like text but its a link? Like where you can c

4条回答
  •  粉色の甜心
    2021-01-01 11:42

    Of course it is possible by invoking some WIN32 functionality into your control, but if you are looking for some standard ways, check this post out: Create hyperlink in TextBox control

    There are some discussions about different ways of integration.

    greetings

    Update 1: The best thing is to follow this method: http://msdn.microsoft.com/en-us/library/f591a55w.aspx

    because the RichText box controls provides some functionality to "DetectUrls". Then you can handle the clicked links very easy:

    this.richTextBox1.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.richTextBox1_LinkClicked);
    

    and you can simple create your own RichTextBox contorl by extending the base class - there you can override the methods you need, for example the DetectUrls.

提交回复
热议问题