ITextEdit::Replace Method (Int32, Int32, String^)
Visual Studio 2015
Replaces a sequence of characters with different text.
Assembly: Microsoft.VisualStudio.Text.Data (in Microsoft.VisualStudio.Text.Data.dll)
Parameters
- startPosition
-
Type:
System::Int32
The buffer position at which to start replacing.
- charsToReplace
-
Type:
System::Int32
The number of characters to replace.
- replaceWith
-
Type:
System::String^
The new text.
Return Value
Type: System::Booleantrue if the replacement succeeded; false if it was prevented by a read-only region.
| Exception | Condition |
|---|---|
| ArgumentNullException | replaceWith is null. |
| InvalidOperationException | |
| ArgumentOutOfRangeException | startPosition is less than zero or greater than the length of the buffer, or charsToReplace is less than zero, or startPosition + charsToReplace is greater than the length of the buffer. |
This method has the same effect as first deleting the charsToReplace and then inserting replaceWith.
Replacing zero characters with an empty string will succeed but will not generate a new snapshot or raise a Changed event.
Show: