This property, in conjunction with the SelLength and SelText 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.
The valid range for this property is 0 to the length of the cell text. Attempting to set this property to a value outside that range will reset this property to the highest acceptable value.
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.
Setting this property changes the selection to an insertion point and sets the SelLength property to 0.
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"; }
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