$99 VS $1000+. UI Control for ASP.NET AJAX(contains chart and gridview).
RichTextBox Control for Windows Forms
Edit rich text content with text formatting options, mail-merge, table, and floating objects, etc.
Home > WinForms UI Controls > User Manual > RichTextBox Hyperlink Element in C#

Hyperlinks of KetticDocument in RichTextBox in C#.NET

KetticRichTextBox control allows the users to insert and customize the hyperlinks in contents of KetticDocument. It provides the hyperlinks functionality in C# classes of HyperlinkInfo, HyperlinkRangeStart, and HyperlinkRangeEnd. The HyperlinkInfo are the objects that allow the users to insert links to the KetticControls for Windows Forms. The HyperlinkRangeStart and HyperlinkRangeEnd are Inline DocumentElements, which are able to be added to the inlines inside a document. In addition, this control allows the users to set the tool tip format of hyperlinks.

Using HyperlinkInfo Objects to Add Links in C#.NET

The HyperlinkInfo of KetticRichTextBox control contains a few properties for the users to insert links to the Kettic UI WinForms controls, for example, IsAnchor, NavigateUri, and Target. The IsAnchor property determines the hyperlink points to a URL or a bookmark. The NavigateUri determines the URI of the hyperlink and the Target property determines the links that will be opened. The C# code below shows how to insert a link to document of KetticRichTextBox.

HyperlinkInfo info = new HyperlinkInfo()
{
NavigateUri = "http://www.kettic.com/winforms_ui/controls_and_tutorials.shtml",
Target = HyperlinkTargets.Blank,
IsAnchor = false
};
this.ketticRichTextBox1.InsertHyperlink(info, "Kettic UI WinForms Controls");

Methods for Inserting a Hyperlink to Document

  • public void InsertHyperlink(), this method is able to insert a hyperlink with custom style and the valid value includes HyperlinkInfo hyperlinkInfo, string hyperlinkText, StyleDefinition hyperlinkStyle
  • public void InsertHyperlink(), this method is able to add a hyperlink to span several different adjacent inlines and the valid values include HyperlinkInfo hyperlinkInfo, IEnumerable inlines
  • public void InsertHyperlink(), this method is used to create a hyperlink from the document part that are currently selected.
  • public void InsertHyperlink(), this method is able to create a hyperlink from the part of the document that are currently selected. And it will change the text style

Remove Hyperlink from Document of KetticRichTextBox

To remove a hyperlink from the document, we are able to position the caret in the hyperlink and invoke by using the C# code snippet as below.

this.ketticRichTextBox1.RemoveHyperlink();

HyperlinkRangeStart and HyperlinkRangeEnd for Inserting Links

KetticRichTextBox control provides the HyperlinkRangeStart and HyperlinkRangeEnd to add hyperlink to inlines of document. The C# code below demonstrates how to create a document with a hyperlink which spans different paragraphs.
The HyperlinkRangeStart and HyperlinkRangeEnd allow the users to implement a custom logic with hyperlink, get the entire hyperlinks from the document, and customize the HyperlinkInfo properties as well as all the parts of the document. The C# code below shows how to delete all hyperlinks in the document and replace the links with text.

More Customizing Options of KetticRichTextBox

ToolTip, the hyperlinks use a fixed string as a tool tip and the users can use the HyperlinkToolTipFormatString of KetticRichTextBox to set the format for all hyperlinks in the document.
HyperlinkClicked, this event will be fired as clicking on a hyperlink and will send the document element like a Span, an Image, InlineUIContainer, and more. This event provides the possibility to mark the handled event and prevent the default action.
UI Controlsfor Windows Forms
.NET WinForms UI Overview.NET WinForms UI Features.NET WinForms UI GuideC# WinForms UI DesignVB.NET WinForms UI Design
WinForms UI Controls