简体   繁体   English

如何使RichText框中的任何文本作为超链接

[英]how to make any text in richtext box as hyperlink

I am having text in rich text box separated with ';' 我在富文本框中以';'分隔的文本 I want to make every value as hyperlink which is separated with ';'. 我想将每个值都设为用';'分隔的超链接。 Please Help 请帮忙

Have a look at the article here. 在这里看看这篇文章。 It shows how to enable hyperlinks in a richtext box http://msdn.microsoft.com/en-us/library/f591a55w.aspx 它显示了如何在富文本框中启用超链接http://msdn.microsoft.com/zh-cn/library/f591a55w.aspx

  1. To link to a Web page with the RichTextBox control 使用RichTextBox控件链接到网页
  2. Set the Text property to a string that includes a valid URL (for example, " http://www.microsoft.com/ "). 将Text属性设置为包含有效URL的字符串(例如,“ http://www.microsoft.com/ ”)。
  3. Make sure the DetectUrls property is set to true (the default). 确保DetectUrls属性设置为true(默认值)。
  4. Create a new global instance of the Process object. 创建一个新的Process对象的全局实例。
  5. Write an event handler for the LinkClicked event that sends the browser the desired text. 为LinkClicked事件编写事件处理程序,该事件处理程序向浏览器发送所需的文本。

Do you mean you have many URLs in rich textbox but they are not shown as links? 您是说您在富文本框中有很多URL,但未将它们显示为链接吗?

Check the DetectUrls property to true. 检查DetectUrls属性为true。

If you have arbitrary text that should be converted to links take a look at: http://www.codeproject.com/Articles/9196/Links-with-arbitrary-text-in-a-RichTextBox 如果您有任意文本应转换为链接,请查看: http : //www.codeproject.com/Articles/9196/Links-with-arbitrary-text-in-a-RichTextBox

To react to user interaction with such a link, as already posted: http://msdn.microsoft.com/en-us/library/f591a55w.aspx 要通过这样的链接对用户交互做出反应,请参见: http : //msdn.microsoft.com/en-us/library/f591a55w.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM