富文本框中的链接? [英] Links inside rich textbox?

查看:69
本文介绍了富文本框中的链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道富文本框可以检测链接(例如 http://www.yahoo.com)但是有一种让我向它添加看起来像文本但它是一个链接的链接的方法?比如在哪里可以选择链接的标签?例如,它不是显示为 http://www.yahoo.com,而是显示为 点击这里进入雅虎

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 choose the label of the link? For example instead of it appearing as http://www.yahoo.com it appears as Click here to go to yahoo

忘记了,我用的是windows窗体

edit: forgot, im using windows forms

有没有更好用的东西(比如更容易格式化)?

edit: is there something thats better to use (as in easier to format)?

推荐答案

当然可以通过将一些 WIN32 功能调用到您的控件中,但是如果您正在寻找一些标准方法,请查看这篇文章:在 TextBox 控件中创建超链接

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.

问候

更新 1:最好的方法是遵循以下方法:http://msdn.microsoft.com/en-us/library/f591a55w.aspx

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

因为 RichText 框控件为DetectUrls"提供了一些功能.然后你可以很容易地处理点击的链接:

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);

并且您可以通过扩展基类来简单地创建您自己的 RichTextBox 控件 - 在那里您可以覆盖您需要的方法,例如 DetectUrls.

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.

这篇关于富文本框中的链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆