Text editing
The editing point is determined by the caret position and selection in RadTextBoxControl. The editing position is visible only if the control is focused.
You can insert text programmatically at concrete position by using the Insert method. At that case, the text is inserted at the position determined by the SelectionStart property. If the SelectionLength property is greater than zero, the inserted text replaces the selected text.
Insert string.
private void Insert()
{
this.radTextBoxControl1.Text = "Green";
this.radTextBoxControl1.CaretIndex = 0;
this.radTextBoxControl1.Insert("John ");
}
Private Sub Insert()
Me.RadTextBoxControl1.Text = "Green"
Me.RadTextBoxControl1.CaretIndex = 0
Me.RadTextBoxControl1.Insert("John ")
End Sub
Alternatively, you can insert text at the end of the RadTextBoxControl content by using the AppendText method:
Append specific string.
private void AppendText()
{
this.radTextBoxControl1.Text = "Samuel";
this.radTextBoxControl1.AppendText(" Jackson");
}
Private Sub AppendText()
Me.RadTextBoxControl1.Text = "Samuel"
Me.RadTextBoxControl1.AppendText(" Jackson")
End Sub
You can delete the selected text or character at the caret position by using the Delete method:
Select and delete a word.
private void DeleteSelection()
{
this.radTextBoxControl1.Text = "John Green";
this.radTextBoxControl1.Select(0, 4);
this.radTextBoxControl1.Delete();
}
Private Sub DeleteSelection()
Me.RadTextBoxControl1.Text = "John Green"
Me.RadTextBoxControl1.[Select](0, 4)
Me.RadTextBoxControl1.Delete()
End Sub
Each editing operation raises the TextChanging and TextChanged events. Notice that you can prevent successful finishing of operation by subscribing to the TextChanging event:
Cancel the ex changing if the entire text is deleted.
private void radTextBoxControl1_TextChanging(object sender, Telerik.WinControls.TextChangingEventArgs e)
{
e.Cancel = string.IsNullOrEmpty(e.NewValue);
}
Private Sub radTextBoxControl1_TextChanging(sender As Object, e As Telerik.WinControls.TextChangingEventArgs)
e.Cancel = String.IsNullOrEmpty(e.NewValue)
End Sub