/
BookmarksAndHyperlinksActions.cs
38 lines (36 loc) · 1.49 KB
/
BookmarksAndHyperlinksActions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using DevExpress.XtraRichEdit;
using DevExpress.XtraRichEdit.API.Native;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DXRichEditControlAPISample.CodeExamples
{
class BookmarksAndHyperlinksActions
{
static void InsertBookmark(Document document)
{
#region #InsertBookmark
document.LoadDocument("Documents//Grimm.docx", DocumentFormat.OpenXml);
document.BeginUpdate();
DocumentPosition pos = document.Range.Start;
document.Bookmarks.Create(document.CreateRange(pos, 0), "Top");
//Insert the hyperlink anchored to the created bookmark:
DocumentPosition pos1 = document.CreatePosition((document.Range.End).ToInt() + 25);
document.Hyperlinks.Create(document.InsertText(pos1, "get to the top"));
document.Hyperlinks[0].Anchor = "Top";
document.EndUpdate();
#endregion #InsertBookmark
}
static void InsertHyperlink(Document document)
{
#region #InsertHyperlink
DocumentPosition hPos = document.Range.Start;
document.Hyperlinks.Create(document.InsertText(hPos, "Follow me!"));
document.Hyperlinks[0].NavigateUri = "https://www.devexpress.com/Products/NET/Controls/WinForms/Rich_Editor/";
document.Hyperlinks[0].ToolTip = "WinForms Rich Text Editor";
#endregion #InsertHyperlink
}
}
}