Skip to main content
A newer version of this page is available. .
.NET Framework 4.5.2+

HyperlinkCollection Interface

An interface that defines a collection of Hyperlink objects.

Namespace: DevExpress.XtraRichEdit.API.Native

Assembly: DevExpress.RichEdit.v19.2.Core.dll

Declaration

[ComVisible(true)]
public interface HyperlinkCollection :
    ReadOnlyHyperlinkCollection,
    ISimpleCollection<Hyperlink>,
    IEnumerable<Hyperlink>,
    IEnumerable,
    ICollection

Remarks

Use the HyperlinkCollection.Create method to add a new hyperlink to the collection.

Document document = richEditControl1.Document;

//Find the specific text string in a document
DocumentRange[] foundRanges = document.FindAll("DevExpress WinForms Rich Text Editor",
SearchOptions.CaseSensitive);
if (foundRanges.Length > 0)
{
    //Create a hyperlink from a found range
    document.Hyperlinks.Create(foundRanges[0]);

    //Set the URI and the tooltip for the created hyperlink
    document.Hyperlinks[0].NavigateUri = "https://www.devexpress.com/Products/NET/Controls/WinForms/Rich_Editor/";
    document.Hyperlinks[0].ToolTip = "WinForms Rich Text Editor";
}

Note

The hyperlink attached to a shape is not added to the HyperlinkCollection. Check the Shape.Hyperlink property to retrieve the hyperlink.

To remove an existing hyperlink, use the HyperlinkCollection.Remove method.

The code sample below locates and removes all hyperlinks in the first section:

using (RichEditDocumentServer wordProcessor = new RichEditDocumentServer())
{
    Document document = wordProcessor.Document;
    ReadOnlyHyperlinkCollection hyperlinks = document.Hyperlinks.Get(document.Sections[0].Range);
    if (hyperlinks != null)
    {
        foreach (Hyperlink hyperlink in hyperlinks)
        {
            document.Hyperlinks.Remove(hyperlink);
        }
    }
}
See Also