ITextSelection ITextSelection ITextSelection ITextSelection Interface

Definition

Represents the currently selected text of a document.

public : interface ITextSelection : ITextRange
struct winrt::Windows::UI::Text::ITextSelection : ITextRange
public interface ITextSelection : ITextRange
Public Interface ITextSelection Implements ITextRange
Inheritance
ITextSelectionITextSelectionITextSelectionITextSelection
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

Interface inheritance

ITextSelection inherits ITextRange. Types that implement ITextSelection also implement the interface members of ITextRange.

Properties

Character Character Character Character

Gets or sets the first character of the text range; that is, the character associated with the StartPosition property.

(Inherited from ITextRange)

CharacterFormat CharacterFormat CharacterFormat CharacterFormat

Gets or sets the character formatting attributes of the text range.

(Inherited from ITextRange)

EndPosition EndPosition EndPosition EndPosition

Gets or sets the end character position of the text range.

(Inherited from ITextRange)

FormattedText FormattedText FormattedText FormattedText

Gets or sets an ITextRange object with the formatted text of the specified range.

(Inherited from ITextRange)

Gravity Gravity Gravity Gravity

Gets or sets the gravity of the text range.

(Inherited from ITextRange)

Length Length Length Length

Gets the count of characters in the text range.

(Inherited from ITextRange)

Link Link Link Link

Gets or sets the URL text associated with a text range.

(Inherited from ITextRange)

Options Options Options Options

Gets and sets text selection options.

public : SelectionOptions Options { get; set; }
SelectionOptions Options(); void Options(SelectionOptions options);
public SelectionOptions Options { get; set; }
Public ReadWrite Property Options As SelectionOptions
Value
SelectionOptions SelectionOptions

The text selection options. Each option is binary, so if a particular option is not set, the text selection has the opposite option. For example, if the Overtype option is not set, the text selection is set to insert mode.

ParagraphFormat ParagraphFormat ParagraphFormat ParagraphFormat

Gets or sets the paragraph formatting attributes of the text range.

(Inherited from ITextRange)

StartPosition StartPosition StartPosition StartPosition

Gets or sets the start position of the text range.

(Inherited from ITextRange)

StoryLength StoryLength StoryLength StoryLength

Gets the count of characters in the story of the text range.

(Inherited from ITextRange)

Text Text Text Text

Gets or sets the plain text of the text range.

(Inherited from Windows.UI.ITextRange.Text)

Type Type Type Type

Retrieves the type of text selection.

public : SelectionType Type { get; }
SelectionType Type();
public SelectionType Type { get; }
Public ReadOnly Property Type As SelectionType
Value
SelectionType SelectionType

The selection type.

Methods

CanPaste(Int32) CanPaste(Int32) CanPaste(Int32) CanPaste(Int32)

Determines whether the Clipboard contains content that can be pasted, using a specified format, into the current text range.

(Inherited from ITextRange)

ChangeCase(LetterCase) ChangeCase(LetterCase) ChangeCase(LetterCase) ChangeCase(LetterCase)

Changes the case of letters in a text range.

(Inherited from ITextRange)

Collapse(Boolean) Collapse(Boolean) Collapse(Boolean) Collapse(Boolean)

Collapses the text range into a degenerate point at either the beginning or end of the range.

(Inherited from ITextRange)

Copy Copy Copy Copy

Copies the text of the text range to the Clipboard.

(Inherited from ITextRange)

Cut Cut Cut Cut

Moves the text of the text range to the Clipboard.

(Inherited from ITextRange)

Delete(TextRangeUnit,Int32) Delete(TextRangeUnit,Int32) Delete(TextRangeUnit,Int32) Delete(TextRangeUnit,Int32)

Deletes text from the text range.

(Inherited from ITextRange)

EndKey(TextRangeUnit, Boolean) EndKey(TextRangeUnit, Boolean) EndKey(TextRangeUnit, Boolean) EndKey(TextRangeUnit, Boolean)

Moves the insertion point or the active end of the text selection to the end of the specified unit, mimicking the functionality of the End key.

public : int EndKey(TextRangeUnit unit, bool extend)
int32_t EndKey(TextRangeUnit unit, bool extend) const;
public int EndKey(TextRangeUnit unit, Boolean extend)
Public Function EndKey(unit As TextRangeUnit, extend As Boolean) As int
Parameters
unit
TextRangeUnit TextRangeUnit

The units by which to move the insertion point or active end. The following values are valid.

extend
Boolean Boolean

Indicates how to change the selection. True extends the selection by moving only the active end. False collapses the selection to an insertion point and then moves the insertion point. The default value is false.

Returns
int int

The number of units that the insertion point or the active end is moved.

Remarks

The EndKey method is a logical method rather than a directional method and so is dependent on the language that is involved. For example, in Arabic text, EndKey moves to the left end of a line, whereas in English text, it moves to the right. Thus EndKey is different from the ITextSelection.MoveRight or ITextSelection.MoveLeft methods. Also, note that the EndKey method is quite different from the End property, which is the character position at the end of the selection. EndKey also differs from the ITextRange.EndOf method in that it extends from the active end, whereas EndOf extends from End.

See Also

EndOf(TextRangeUnit,Boolean) EndOf(TextRangeUnit,Boolean) EndOf(TextRangeUnit,Boolean) EndOf(TextRangeUnit,Boolean)

Moves or extends the text range to the end of the nearest specified text unit. The text range is moved or extended forward in the document.

(Inherited from ITextRange)

Expand(TextRangeUnit) Expand(TextRangeUnit) Expand(TextRangeUnit) Expand(TextRangeUnit)

Expands a text range to completely contain any partial text units.

(Inherited from ITextRange)

FindText(String,Int32,FindOptions) FindText(String,Int32,FindOptions) FindText(String,Int32,FindOptions) FindText(String,Int32,FindOptions)

Searches for a particular text string in a range and, if found, selects the string.

(Inherited from ITextRange)

GetClone GetClone GetClone GetClone

Creates a new object that is identical to this text range object.

(Inherited from ITextRange)

GetIndex(TextRangeUnit) GetIndex(TextRangeUnit) GetIndex(TextRangeUnit) GetIndex(TextRangeUnit)

Retrieves the story index of the text unit (word, line, sentence, paragraph, and so on) at the starting character position of the text range.

(Inherited from ITextRange)

GetTextViaStream(TextGetOptions,IRandomAccessStream) GetTextViaStream(TextGetOptions,IRandomAccessStream) GetTextViaStream(TextGetOptions,IRandomAccessStream) GetTextViaStream(TextGetOptions,IRandomAccessStream)

Retrieves the text in the text range according to the specified conversion flags, as a random access stream.

(Inherited from ITextRange)

HomeKey(TextRangeUnit, Boolean) HomeKey(TextRangeUnit, Boolean) HomeKey(TextRangeUnit, Boolean) HomeKey(TextRangeUnit, Boolean)

Moves the insertion point or the active end of the text selection to the home position, mimicking the functionality of the Home key.

public : int HomeKey(TextRangeUnit unit, bool extend)
int32_t HomeKey(TextRangeUnit unit, bool extend) const;
public int HomeKey(TextRangeUnit unit, Boolean extend)
Public Function HomeKey(unit As TextRangeUnit, extend As Boolean) As int
Parameters
unit
TextRangeUnit TextRangeUnit

The units by which to move the insertion point or active end. The following values are valid.

extend
Boolean Boolean

Indicates how to change the selection. True extends the selection by moving only the active end. False collapses the selection to an insertion point and then moves the insertion point. The default value is false.

Returns
int int

The number of units that the insertion point or the active end is moved.

Remarks

The HomeKey method is a logical method rather than a directional method and so is dependent on the language that is involved. For example, in Arabic text, HomeKey moves to the right end of a line, whereas in English text, it moves to the left. Thus HomeKey is different from the ITextSelection.MoveRight or ITextSelection.MoveLeft methods. HomeKey also differs from the ITextRange.StartOf method in that it extends from the active end, whereas StartOf extends from the start position.

See Also

InRange(ITextRange) InRange(ITextRange) InRange(ITextRange) InRange(ITextRange)

Determines whether this range is in or at the same text as a specified range.

(Inherited from ITextRange)

InStory(ITextRange) InStory(ITextRange) InStory(ITextRange) InStory(ITextRange)

Determines whether this range's story is the same as a specified range's story.

(Inherited from ITextRange)

InsertImage(Int32,Int32,Int32,VerticalCharacterAlignment,String,IRandomAccessStream) InsertImage(Int32,Int32,Int32,VerticalCharacterAlignment,String,IRandomAccessStream) InsertImage(Int32,Int32,Int32,VerticalCharacterAlignment,String,IRandomAccessStream) InsertImage(Int32,Int32,Int32,VerticalCharacterAlignment,String,IRandomAccessStream)

Inserts an image into this range.

(Inherited from ITextRange)

IsEqual(ITextRange) IsEqual(ITextRange) IsEqual(ITextRange) IsEqual(ITextRange)

Determines whether this range has the same character positions and story as those of a specified range.

(Inherited from ITextRange)

MatchSelection MatchSelection MatchSelection MatchSelection

Sets the start and end positions of this range to match the active selection.

(Inherited from ITextRange)

Move(TextRangeUnit,Int32) Move(TextRangeUnit,Int32) Move(TextRangeUnit,Int32) Move(TextRangeUnit,Int32)

Moves the insertion point forward or backward by the specified number of units. If the text range is nondegenerate, it is collapsed to an insertion point at the start or end position of the text range, depending on count, and then is moved.

(Inherited from ITextRange)

MoveDown(TextRangeUnit, Int32, Boolean) MoveDown(TextRangeUnit, Int32, Boolean) MoveDown(TextRangeUnit, Int32, Boolean) MoveDown(TextRangeUnit, Int32, Boolean)

Moves the insertion point or the active end of the text selection down, mimicking the functionality of the Down Arrow or Page Down key.

public : int MoveDown(TextRangeUnit unit, int count, bool extend)
int32_t MoveDown(TextRangeUnit unit, int32_t count, bool extend) const;
public int MoveDown(TextRangeUnit unit, Int32 count, Boolean extend)
Public Function MoveDown(unit As TextRangeUnit, count As Int32, extend As Boolean) As int
Parameters
unit
TextRangeUnit TextRangeUnit

The units by which to move the insertion point or active end. The following values are valid.

ValueCorresponding key combinationMeaning
LineDown ArrowMoves down one line. This is the default.
ParagraphCtrl+Down ArrowMoves down one paragraph.
ScreenPage DownMoves down one screen.
WindowCtrl+Page DownMoves to the last character in the window.

count
Int32 Int32

The number of units to move. The default value is 1.

extend
Boolean Boolean

Indicates how to change the selection. True extends the selection by moving only the active end. False collapses the selection to an insertion point and then moves the insertion point. The default value is false.

Returns
int int

The number of units that the insertion point or active end moved down. Collapsing the selection counts as one unit.

Remarks

A nonzero extend value corresponds to the Shift key being pressed in addition to the key combination described in unit.

See Also

MoveEnd(TextRangeUnit,Int32) MoveEnd(TextRangeUnit,Int32) MoveEnd(TextRangeUnit,Int32) MoveEnd(TextRangeUnit,Int32)

Moves the end position of the text range.

(Inherited from ITextRange)

MoveLeft(TextRangeUnit, Int32, Boolean) MoveLeft(TextRangeUnit, Int32, Boolean) MoveLeft(TextRangeUnit, Int32, Boolean) MoveLeft(TextRangeUnit, Int32, Boolean)

Moves the insertion point or the active end of the text selection to the left, mimicking the functionality of the Left Arrow key.

public : int MoveLeft(TextRangeUnit unit, int count, bool extend)
int32_t MoveLeft(TextRangeUnit unit, int32_t count, bool extend) const;
public int MoveLeft(TextRangeUnit unit, Int32 count, Boolean extend)
Public Function MoveLeft(unit As TextRangeUnit, count As Int32, extend As Boolean) As int
Parameters
unit
TextRangeUnit TextRangeUnit

The units by which to move the insertion point or active end. The following values are valid.

ValueCorresponding key combinationMeaning
CharacterLeft ArrowMove one character position to the left. This is the default.
WordCtrl+Left ArrowMove one word to the left.

count
Int32 Int32

The number of units to move. The default value is 1. If count is less than zero, movement is to the right.

extend
Boolean Boolean

Indicates how to change the selection. True extends the selection by moving only the active end. False collapses the selection to an insertion point and then moves the insertion point. The default value is false.

Returns
int int

The number of units that the insertion point or active end moved. Collapsing the selection counts as one unit.

Remarks

A nonzero extend value corresponds to the Shift key being pressed in addition to the key combination described in unit.

See Also

MoveRight(TextRangeUnit, Int32, Boolean) MoveRight(TextRangeUnit, Int32, Boolean) MoveRight(TextRangeUnit, Int32, Boolean) MoveRight(TextRangeUnit, Int32, Boolean)

Moves the insertion point or the active end of the text selection to the right, mimicking the functionality of the Right Arrow key.

public : int MoveRight(TextRangeUnit unit, int count, bool extend)
int32_t MoveRight(TextRangeUnit unit, int32_t count, bool extend) const;
public int MoveRight(TextRangeUnit unit, Int32 count, Boolean extend)
Public Function MoveRight(unit As TextRangeUnit, count As Int32, extend As Boolean) As int
Parameters
unit
TextRangeUnit TextRangeUnit

The units by which to move the insertion point or active end. The following values are valid.

ValueCorresponding key combinationMeaning
CharacterRight ArrowMove one character position to the right. This is the default.
WordCtrl+Right ArrowMove one word to the right.

count
Int32 Int32

The number of units to move. The default value is 1. If count is less than zero, movement is to the left.

extend
Boolean Boolean

Indicates how to change the selection. True extends the selection by moving only the active end. False collapses the selection to an insertion point and then moves the insertion point. The default value is false.

Returns
int int

The number of units that the insertion point or active end moved. Collapsing the selection counts as one unit.

Remarks

A nonzero extend value corresponds to the Shift key being pressed in addition to the key combination described in unit.

See Also

MoveStart(TextRangeUnit,Int32) MoveStart(TextRangeUnit,Int32) MoveStart(TextRangeUnit,Int32) MoveStart(TextRangeUnit,Int32)

Moves the start position of a text range.

(Inherited from ITextRange)

MoveUp(TextRangeUnit, Int32, Boolean) MoveUp(TextRangeUnit, Int32, Boolean) MoveUp(TextRangeUnit, Int32, Boolean) MoveUp(TextRangeUnit, Int32, Boolean)

Moves the insertion point or the active end of the text selection up, mimicking the functionality of the Up Arrow or Page Up keys.

public : int MoveUp(TextRangeUnit unit, int count, bool extend)
int32_t MoveUp(TextRangeUnit unit, int32_t count, bool extend) const;
public int MoveUp(TextRangeUnit unit, Int32 count, Boolean extend)
Public Function MoveUp(unit As TextRangeUnit, count As Int32, extend As Boolean) As int
Parameters
unit
TextRangeUnit TextRangeUnit

The units by which to move the insertion point or active end. The following values are valid.

ValueCorresponding key combinationMeaning
LineUp ArrowMoves up one line. This is the default.
ParagraphCtrl+Up ArrowMoves up one paragraph.
ScreenPage UpMoves up one screen.
WindowCtrl+Page UpMoves to the first character in the window.

count
Int32 Int32

The number of units to move. The default value is 1.

extend
Boolean Boolean

Indicates how to change the selection. True extends the selection by moving only the active end. False collapses the selection to an insertion point and then moves the insertion point. The default value is false.

Returns
int int

The number of units the insertion point or active end is moved down. Collapsing the selection counts as one unit.

Remarks

A nonzero extend value corresponds to the Shift key being pressed in addition to the key combination described in unit.

See Also

Paste(Int32) Paste(Int32) Paste(Int32) Paste(Int32)

Pastes text from the Clipboard into the text range.

(Inherited from ITextRange)

ScrollIntoView(PointOptions) ScrollIntoView(PointOptions) ScrollIntoView(PointOptions) ScrollIntoView(PointOptions)

Scrolls this text range into view.

(Inherited from ITextRange)

SetIndex(TextRangeUnit,Int32,Boolean) SetIndex(TextRangeUnit,Int32,Boolean) SetIndex(TextRangeUnit,Int32,Boolean) SetIndex(TextRangeUnit,Int32,Boolean)

Moves the text range to the specified unit of the story.

(Inherited from ITextRange)

SetPoint(Point,PointOptions,Boolean) SetPoint(Point,PointOptions,Boolean) SetPoint(Point,PointOptions,Boolean) SetPoint(Point,PointOptions,Boolean)

Changes the text range based on the specified point.

(Inherited from ITextRange)

SetRange(Int32,Int32) SetRange(Int32,Int32) SetRange(Int32,Int32) SetRange(Int32,Int32)

Sets the endpoints of the text range to the specified values.

(Inherited from ITextRange)

SetText(TextSetOptions,String) SetText(TextSetOptions,String) SetText(TextSetOptions,String) SetText(TextSetOptions,String)

Replaces the text in the text range.

(Inherited from ITextRange)

SetTextViaStream(TextSetOptions,IRandomAccessStream) SetTextViaStream(TextSetOptions,IRandomAccessStream) SetTextViaStream(TextSetOptions,IRandomAccessStream) SetTextViaStream(TextSetOptions,IRandomAccessStream)

Sets the text in the text range based on the contents of a random access stream.

(Inherited from ITextRange)

StartOf(TextRangeUnit,Boolean) StartOf(TextRangeUnit,Boolean) StartOf(TextRangeUnit,Boolean) StartOf(TextRangeUnit,Boolean)

Moves or extends the text range to the start of the nearest specified text unit. The text range is moved or extended backward in the document.

(Inherited from ITextRange)

TypeText(String) TypeText(String) TypeText(String) TypeText(String)

Enters text into the selection as if someone typed it.

public : void TypeText(Platform::String value)
void TypeText(winrt::hstring value) const;
public void TypeText(String value)
Public Function TypeText(value As String) As void
Parameters
value
String String

The text string to type into this selection.

Remarks

This method is similar to the underlying ITextDocument.SetText method, but is sensitive to the Insert or Overtype key state and UI settings like AutoCorrect and smart quotes.

See Also