SelStart および SelText プロパティと併用するこのプロパティは、挿入ポイントの設定、挿入範囲の確立、サブ文字列の選択、または編集されるセルのテキストをクリアなどの作業に役立ちます。
このプロパティの有効範囲は、セル テキスト長に対して 0 です。このプロパティを範囲外の値に設定しようとすると、このプロパティは受け入れられる最大値にリセットされます。
このプロパティは、IsInEditMode プロパティを使用して決定できる、コントロールが編集モードである場合に限って設定または取得できます。コントロールが編集モードであれば、ActiveCell プロパティはセルが現在編集されていることを決定するために使用できます。コントロールが編集モードでなければ、このプロパティを使用しようとするとエラーが発生します。
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"; }