Back to Devexpress

HyperlinkCollection.Create(DocumentRange) Method

officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-hyperlinkcollection-dot-create-x28-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-documentrange-x29.md

latest6.8 KB
Original Source

HyperlinkCollection.Create(DocumentRange) Method

Creates a hyperlink for the specified document range and adds it to the collection.

Namespace : DevExpress.XtraRichEdit.API.Native

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

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
Hyperlink Create(
    DocumentRange range
)
vb
Function Create(
    range As DocumentRange
) As Hyperlink

Parameters

NameTypeDescription
rangeDocumentRange

A range associated with the hyperlink.

|

Returns

TypeDescription
Hyperlink

The created hyperlink.

|

Remarks

The Create method creates a hyperlink with the specified Hyperlink.Range and other characteristics set to null. Use the Hyperlink class properties to adjust the newly created hyperlink.

You can use the Create method overload to convert a document range to a hyperlink. Refer to the following article for a code sample:

Read Tutorial: How to: Convert a Static URI to a Hyperlink

To remove a hyperlink, use the HyperlinkCollection.Remove method.

Tip

Use the Shape.AddHyperlink method to associate a hyperlink with a Shape object. Note that this hyperlink is not added to the HyperlinkCollection.

The following code snippets (auto-collected from DevExpress Examples) contain references to the Create(DocumentRange) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-richedit-document-api/CS/RichEditAPISample/CodeExamples/BookmarksAndHyperlinks.cs#L22

csharp
DocumentPosition pos1 = document.CreatePosition((document.Range.End).ToInt()+25);
document.Hyperlinks.Create(document.InsertText(pos1, "get to the top"));
document.Hyperlinks[0].Anchor = "Top";

wpf-richedit-document-api/CS/DXRichEditControlAPISample/CodeExamples/BookmarksAndHyperlinksActions.cs#L22

csharp
DocumentPosition pos1 = document.CreatePosition((document.Range.End).ToInt() + 25);
document.Hyperlinks.Create(document.InsertText(pos1, "get to the top"));
document.Hyperlinks[0].Anchor = "Top";

word-document-api-examples/CS/CodeExamples/BookmarksAndHyperlinks.cs#L31

csharp
DocumentRange hyperlinkRange = wordProcessor.Document.AppendText("get to the top");
document.Hyperlinks.Create(hyperlinkRange);
document.Hyperlinks[0].Anchor = "Top";

word-document-api-insert-dynamic-content/CS/Program.cs#L85

csharp
{
    Hyperlink hyperlink = document.Hyperlinks.Create(range);
    hyperlink.NavigateUri = item.Links[0].Uri.ToString();

winforms-richedit-document-api/VB/RichEditAPISample/CodeExamples/BookmarksAndHyperlinks.vb#L21

vb
Dim pos1 As DevExpress.XtraRichEdit.API.Native.DocumentPosition = document.CreatePosition((document.Range.[End]).ToInt() + 25)
document.Hyperlinks.Create(document.InsertText(pos1, "get to the top"))
document.Hyperlinks(CInt((0))).Anchor = "Top"

wpf-richedit-document-api/VB/DXRichEditControlAPISample/CodeExamples/BookmarksAndHyperlinksActions.vb#L19

vb
Dim pos1 As DocumentPosition = document.CreatePosition((document.Range.End).ToInt() + 25)
document.Hyperlinks.Create(document.InsertText(pos1, "get to the top"))
document.Hyperlinks(0).Anchor = "Top"

word-document-api-examples/VB/CodeExamples/BookmarksAndHyperlinks.vb#L31

vb
Dim hyperlinkRange As DocumentRange = wordProcessor.Document.AppendText("get to the top")
document.Hyperlinks.Create(hyperlinkRange)
document.Hyperlinks(0).Anchor = "Top"

word-document-api-insert-dynamic-content/VB/Module1.vb#L72

vb
If item.Links.Count > 0 Then
    Dim hyperlink As Hyperlink = document.Hyperlinks.Create(range)
    hyperlink.NavigateUri = item.Links(0).Uri.ToString()

See Also

HyperlinkCollection Interface

HyperlinkCollection Members

DevExpress.XtraRichEdit.API.Native Namespace