ICSharpCode.TextEditor.Document.SelectionManager.SetSelection C# (CSharp) Method

SetSelection() public method

Clears the selection and sets a new selection using the given ISelection object.
public SetSelection ( ISelection selection ) : void
selection ISelection
return void
        public void SetSelection(ISelection selection)
        {
            //			autoClearSelection = false;
            if (selection != null) {
                if (SelectionCollection.Count == 1 &&
                    selection.StartPosition == SelectionCollection[0].StartPosition &&
                    selection.EndPosition == SelectionCollection[0].EndPosition ) {
                    return;
                }
                ClearWithoutUpdate();
                selectionCollection.Add(selection);
                document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.LinesBetween, selection.StartPosition.Y, selection.EndPosition.Y));
                document.CommitUpdate();
                OnSelectionChanged(EventArgs.Empty);
            } else {
                ClearSelection();
            }
        }

Same methods

SelectionManager::SetSelection ( Point startPosition, Point endPosition ) : void

Usage Example

		/// <summary>
		/// Selects the specified text range.
		/// </summary>
		static void SelectText(SelectionManager selectionManager, IDocument document, int startOffset, int length)
		{
			selectionManager.ClearSelection();
			TextLocation selectionStart = document.OffsetToPosition(startOffset);
			TextLocation selectionEnd = document.OffsetToPosition(startOffset + length);
			selectionManager.SetSelection(selectionStart, selectionEnd);
		}
All Usage Examples Of ICSharpCode.TextEditor.Document.SelectionManager::SetSelection