Imports Infragistics.Win Imports Infragistics.Win.UltraWinEditors Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ' Set focus to the control so we can use the text selection related ' properties. Me.UltraTextEditor1.Focus() Me.UltraTextEditor1.Text = "[Selected Text]" ' Set the start of the selection to the second character Me.UltraTextEditor1.SelectionStart = 1 ' Set the length of the selection to the value of the TextLength ' property minus 2, which will result in all of the text inside the square ' brackets being selected Me.UltraTextEditor1.SelectionLength = Me.UltraTextEditor1.TextLength - 2 ' Set the SelectedText property, which will result in the currently ' selected text being replaced with the value of the SelectedText ' property. Me.UltraTextEditor1.SelectedText = "Changed" ' Set the SelectionLength property to 0, which will result ' in all of the text becoming deselected. Me.UltraTextEditor1.SelectionLength = 0 ' Set the ReadOnly property to true so the text cannot be changed Me.UltraTextEditor1.ReadOnly = True End Sub
using System.Diagnostics; using Infragistics.Win; using Infragistics.Win.UltraWinEditors; private void button1_Click(object sender, System.EventArgs e) { // Set focus to the control so we can use the text selection related // properties. this.ultraTextEditor1.Focus(); this.ultraTextEditor1.Text = "[Selected Text]"; // Set the start of the selection to the second character this.ultraTextEditor1.SelectionStart = 1; // Set the length of the selection to the value of the TextLength // property minus 2, which will result in all of the text inside the square // brackets being selected this.ultraTextEditor1.SelectionLength = this.ultraTextEditor1.TextLength - 2; // Set the SelectedText property, which will result in the currently // selected text being replaced with the value of the SelectedText // property. this.ultraTextEditor1.SelectedText = "Changed"; // Set the SelectionLength property to 0, which will result // in all of the text becoming deselected. this.ultraTextEditor1.SelectionLength = 0; // Set the ReadOnly property to true so the text cannot be changed this.UltraTextEditor1.ReadOnly = true; }