奇怪的转变在选择框中富文本V5文本时​​包含超链接 [英] Strange shift when Selecting text in richtext box v5 that contains hyperlinks

查看:373
本文介绍了奇怪的转变在选择框中富文本V5文本时​​包含超链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我用RichTextBox.Select(INT开始,INT长度)函数来选择包含超链接了丰富的文本框中的文本,还有在选择一些转变,当我尝试选择的是超链接之后的文字。

When I use the RichTextBox.Select(int start, int length) function to select text in a rich text box that contains hyperlinks, there is some shift in the selection when I try to select any text that is after the hyperlink.

当我删除了超链接,选择正常工作

When I remove the hyperlink, the selection works properly.

编辑:
我用的RichTextBox 5(在Visual Studio中的默认是版本4)

I use RichTextBox 5 (the default in Visual Studio is version 4)

public class RichText50W : RichTextBox
{
    [DllImport("kernel32.dll", CharSet = CharSet.Auto)]
    static extern IntPtr LoadLibrary(string lpFileName);
    protected override CreateParams CreateParams
    {
        get
        {
            CreateParams prams = base.CreateParams;
            if (LoadLibrary("msftedit.dll") != IntPtr.Zero)
            {
                prams.ClassName = "RICHEDIT50W";
            }
            return prams;
        }
    }
}



只有RichTextBox中出现的问题5 +。

The problem occurs only with richtextbox 5+.

这些图像显示问题和行为的差异。

These images show the problem and the difference in behavior.

如果您尝试此确认设置richtextboxes的HideSelection属性设置为假。

If you try this make sure to set HideSelection property of richtextboxes to "false".

选择功能显示上的按钮。

Select functions are displayed on the buttons.

< IMG SRC =http://i.stack.imgur.com/qgrCy.jpgALT =选择(10,1)>

有关RTB5,' E'在文本应该在上面的图片中选择。

For RTB5, 'e' in "Text" should be selected in the above image.

选择(40,1)

显然RTB5选择一些隐藏的文本。

Apparently RTB5 selects some hidden text.

我需要它来选择仅基于可见文本。

I need it to select based on the visible text only.

RTB 4使用表时,所以我不希望使用它有问题。

RTB 4 has problems when using tables, so I don't want to use it.

我使用.NET 2.0

I use .NET 2.0

修改:要试试这个在Visual Studio中,开始使用默认的RichTextBox并改变其声明到RichText50W而不是RichTextBox的

To try this in Visual Studio, start with the default richtextbox and change its declaration to RichText50W instead of RichTextBox

此外RICHEDIT 6有同样的问题。

Also RichEdit 6 has the same issue.

感谢

推荐答案

从我自己的经验,版本RICHEDIT50W与嵌入链接使用或隐藏的文本时,是可怕的坏了(使用RTF代码\v \v0)

From my own experience, version "RICHEDIT50W" is horribly broken when used with embedded hyperlinks or hidden text (using rtf codes \v \v0).

在您V5中,在 Text.Length 属性报告14个字符 - 它显示。在正文长度属性报告51个字符。在 SelectionStart SelectionLength 属性的所有报告隐藏文本的数字,但控制不给你一个方法来在获得隐藏文本下去了。这意味着文本和相关文本选择当你的富文本已隐藏字符的信息变得不可用。

In your v5 box, the Text.Length property reports 14 characters — what it displays. The TextLength property reports 51 characters. The SelectionStart and SelectionLength properties all report the "hidden text" numbers, but the control does not give you a way to get at the hidden text any longer. It means the "text" and related "text selection" information becomes unusable when your rich text has hidden characters.

我认为唯一的解决办法是不使用的RICHEDIT50W 的版本是否会有隐藏字符或浏览市场,共创富文本控件。

I think the only solution is to not use the "RICHEDIT50W" version if there will be hidden characters or browse the market for a better rich text control.

这篇关于奇怪的转变在选择框中富文本V5文本时​​包含超链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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