Version

SelText Property

Returns or sets the selected text of the cell being edited. Note: The cell must be in edit mode and the editor being used for the cell must support selectable text. Otherwise this property will throw a NotSupportedException.
Syntax
'Declaration
 
Public Property SelText As String
public string SelText {get; set;}
Remarks

This property, in conjunction with the SelLength and SelStart properties, is useful for tasks such as setting the insertion point, establishing an insertion range, selecting substrings, or clearing text in the cell being edited.

Setting this property to a new value sets the SelLength property to 0 and replaces the selected text with the specified text.

This property can only be set or retrieved when the control is in edit mode, which can be determined by using the IsInEditMode property. If the control is in edit mode, the ActiveCell property can be used to determine which cell is currently being edited. If the control is not in edit mode, attempting to use this property will generate an error.

Note: Accessing this property will throw an exception if the cell is not in edit mode or the underlying editor being used does not support selectable text, that is its Infragistics.Win.EmbeddableEditorBase.SupportsSelectableText must return true.

Example
Following code demonstrates SelStart, SelText, and SelLength properties off the UltraGridCell. They are only supported while the cell is in edit mode and the underlying embeddable editor supports text selection. Most editors support text selection however editors like CheckEditor or OptionSetEditor do not support text selection. The cell throws an exception if these conditions are not met.

Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinGrid
Imports System.Diagnostics

   Private Sub Func()

       Dim activeCell As UltraGridCell = Me.UltraGrid1.ActiveCell

       ' Ensure that a cell is in edit mode before accessing any of these properties.
       ' Otherwise the cell will throw an exception since these properties only make
       ' sense if the cell is in edit mode.
       If activeCell Is Nothing OrElse Not activeCell.IsInEditMode Then
           Debug.WriteLine("There is no cell in edit mode.")
           Return
       End If

       ' Ensure that the editor being used for editing the cell supports text selection.
       ' Otherwise the cell will throw an exception since these properties only make
       ' sense for editors that support text selection.
       If Not activeCell.Column.Editor.SupportsSelectableText Then
           Debug.WriteLine("The Editor being used for editing the cell doesn't support text selection.")
           Return
       End If

       ' Write out the values of SelStart, SelLength and SelText properties.
       Debug.WriteLine("Selection start	= " & activeCell.SelStart)
       Debug.WriteLine("Selection length	= " & activeCell.SelLength)
       Debug.WriteLine("Selected text		= " & activeCell.SelText)

       ' You can also set these properties. Setting the SelStart positions the caret at the 
       ' specified character position.
       activeCell.SelStart = 0

       ' Setting the SelLength to a non-zero value selects text starting from SelStart position.
       activeCell.SelLength = activeCell.Column.Editor.TextLength

       ' You can set the SelText to replace the currently selected text.
       activeCell.SelText = "Replacement Text"

   End Sub
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
using System.Diagnostics;

private void func( )
{

	UltraGridCell activeCell = this.ultraGrid1.ActiveCell;

	// Ensure that a cell is in edit mode before accessing any of these properties.
	// Otherwise the cell will throw an exception since these properties only make
	// sense if the cell is in edit mode.
	if ( null == activeCell || !activeCell.IsInEditMode )
	{
		Debug.WriteLine( "There is no cell in edit mode." );
		return;
	}

	// Ensure that the editor being used for editing the cell supports text selection.
	// Otherwise the cell will throw an exception since these properties only make
	// sense for editors that support text selection.
	if ( !activeCell.Column.Editor.SupportsSelectableText )
	{
		Debug.WriteLine( "The Editor being used for editing the cell doesn't support text selection." );
		return;
	}

	// Write out the values of SelStart, SelLength and SelText properties.
	Debug.WriteLine( "Selection start	= " + activeCell.SelStart );
	Debug.WriteLine( "Selection length	= " + activeCell.SelLength );
	Debug.WriteLine( "Selected text		= " + activeCell.SelText );

	// You can also set these properties. Setting the SelStart positions the caret at the 
	// specified character position.
	activeCell.SelStart = 0;

	// Setting the SelLength to a non-zero value selects text starting from SelStart position.
	activeCell.SelLength = activeCell.Column.Editor.TextLength;

	// You can set the SelText to replace the currently selected text.
	activeCell.SelText = "Replacement Text";

}
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also