HyperlinkCollection.Create(DocumentPosition, Int32) Method
Creates a hyperlink for the document range, starting at the specified position, and extending through the specified length and adds it to the collection.
Namespace: DevExpress.XtraRichEdit.API.Native
Assembly: DevExpress.RichEdit.v19.2.Core.dll
Declaration
Parameters
Name | Type | Description |
---|---|---|
start | DocumentPosition | A DocumentPosition object specifying a starting position of a range associated with the hyperlink. |
length | Int32 | An integer specifying the length of a hyperlink’s range. |
Returns
Type | Description |
---|---|
Hyperlink | A Hyperlink interface exposing the created hyperlink. |
Remarks
The Create method creates a hyperlink with the specified Hyperlink.Range and other characteristics set to null. Use Hyperlink properties to adjust the newly created hyperlink as required.
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 code sample below creates a hyperlink:
Note
A complete sample project is available at https://github.com/DevExpress-Examples/bookmarks-and-hyperlinks-simple-example-t548777
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";
}