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

Positioning in RichTextBox in C#.NET

KetticRichTextBox control provides the positioning feature for the developers to customize the navigations in the document. This feature is able to position the element of a document at a specific part and track the movement of the caret to manage the selection in the document. The KetticRichTextBox control contains the DocumentPosition C# class for the developers to implement the positioning functionality and set the text selection in document.

Positioning Methods of KetticRichTextBox

KetticRichTextBox WinForms control contains various methods within the DocumentPosition C# class for the developers to set the positioning in the document.
  • NavigateToNextWord(),NavigateToPreviousWord(),NavigateToCurrentLineStart/End(), these positioning methods are able to navigate to a given element in the document.
  • GetCurrentSpanBox(), GetCurrentParagraphBox(), GetCurrentSectionBox(), these positioning are included in the DocumentPosition C# class too. They are able to get information of the elements at a given position, such as the elements, span, paragraph, and section etc.
  • Document.CaretPosition, this method is used to move the caret through arrow keys or mouse.
  • DocumentPosition.SetPosition, this method is used to obtain the DocumentPosition C# class via assigning the coordinates of a point in the document of KetticRichTextBox
The DocumentPosition C# class also allows the users to customize the operators of equality and comparison as they define the position before or after another one in the document. In addition, this control also allows the developers to manage the caret position for a particular KetticDocument via accessing the CaretPosition property or creating a new instance of the DocumentPosition C# class.

Setting of CaretPosition Property of DocumentPosition

The following is the C# code sample that shows how to set the CaretPosition property of the current word.

string currentSpanText = this.ketticRichTextBox1.Document.CaretPosition.GetCurrentSpanBox().Text;

DocumentPosition C# Class of KetticRichTextBox Component

The C# code snippet below demonstrates how to create an instance of the DocumentPosition C# class through accessing the CaretPostion property.

DocumentPosition position = new DocumentPosition(this.ketticRichTextBox1.Document);
string currentSpanText1 = position.GetCurrentSpanBox().Text;
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