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

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

问题描述

我知道富文本框可以检测到链接(例如 http://www.yahoo.com )但是在那里一种方式让我添加链接到它看起来像文本,但它的链接?在哪里可以选择链接的标签?例如,它显示为 http://www.yahoo.com 。 ://www.yahoo.comrel =noreferrer>点击此处转到雅虎

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

因为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天全站免登陆