$99 VS $1000+. UI Control for ASP.NET AJAX(contains chart and gridview).
Text Box Control for Windows Forms
Highly customizable and themable Text Box Control for Windows Forms C# project
Home > WinForms UI Controls > User Manual > Caret Position and Selection in C#

Positioning and Selection in Text Box C# Control

The Kettic Text Box WinForms Control provides the support of positioning and selection in Text Box Control in C# code, which can also be done by using keyboard and mouse input. If we use the keyboard and mouse, we can hold the shift key and then leave the mouse button or use one of the array keys to choose text in the Text Box. The following content shows how to position and select text by using C# code.

C# Code to Position and Select Text

There are two selection properties available to perform the selection in C# code to the Text Box Control, the SelectBeign and the SelectWidth. The SelectBeign property uses a number to indicate the insertion position in the string of the text. The number of 0 is the most positions of the insertion position. When a value given to the property is larger than the number of characters in the text box, the last character will be the insertion point. The SelectWidth property is used to adjust the insertion point width via assigning a value to it.

private void SetSelection()
this.ketticTextBoxControl.Text = "Morning, Steven";
this.ketticTextBoxControl.SelectBegin = 9;
this.ketticTextBoxControl.SelectWidth = 5;
Another way of choosing the same text is to use the Select method,

private void SelectText()
this.ketticTextBoxControl1.Text = "Morning, Steven";
this.ketticTextBoxControl1.Select(9, 5);
If developers need to choose the complete text, they are able to utilize the ChooseComplete method in the ChosenText property to access the selected 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