Skip to main content

Hyperlinks and Bookmarks

  • 2 minutes to read
In This Article

#Bookmark

A Bookmark exposes a document range with a name. The range can have a zero length. The name should start with a letter and must be unique in the collection of bookmarks in the current document. This collection is accessible via the SubDocument.Bookmarks property.

To create a new bookmark and add it to the bookmark collection, use the SubDocument.CreateBookmark method. The SubDocument.SelectBookmark method is helpful if you want to select a bookmark. The SubDocument.RemoveBookmark method deletes the specified bookmark.

Apart from Document methods, XtraRichEdit provides several commands for bookmarks - the CreateBookmarkCommand that creates a bookmark for the selected range and the ShowBookmarkFormCommand that invokes the Bookmark form illustrated in the following picture.

DXRichEdit_Bookmark_Form

You can visualize a bookmark and specify its color via the RichEditControlOptionsBase.Bookmarks property.

Bookmarks in the document can be referenced by a Hyperlink. The Hyperlink.Anchor property specifies the bookmark to which the hyperlink is pointing.

The Hyperlink marks the document range as the hot spot in the document. It can be activated by clicking to navigate the location specified by Hyperlink.NavigateUri (or Hyperlink.Anchor if it is linked to a Bookmark). The link is opened in the frame specified by the Hyperlink.Target property. Hyperlink has a Hyperlink.ToolTip and can be marked as Visited.

Hyperlinks are contained in the SubDocument.Hyperlinks collection of a document. To create a new hyperlink and add it to the collection, use the SubDocument.CreateHyperlink method or invoke the end-user form via the ShowHyperlinkFormCommand command. The Edit hyperlink form is illustrated in the following picture.

DXRichEdit_Hyperlink_Form

When clicked (or activated by another means), a hyperlink fires the RichEditControl.HyperlinkClick event.

Common hyperlink characteristics, such as the key modifier, required for activating the hyperlink by mouse click, as well as tooltip visibility, can be specified via the RichEditControlOptionsBase.Hyperlinks options of the RichEditControl. For example, to activate a hyperlink with a simple mouse click, without having to hold the CTRL key, set the HyperlinkOptions.ModifierKeys to the System.Windows.Forms.Keys.None value.