ITextEdit.Replace Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
Replace(Span, String) |
Replaces a sequence of characters with different text. This method has the same effect as first deleting the characters in
|
Replace(Int32, Int32, String) |
Replaces a sequence of characters with different text. This method has the same effect as first deleting the
|
Replace(Span, String)
Replaces a sequence of characters with different text. This method has the same effect as first deleting the characters in
replaceSpan
and then inserting replaceWith
.
public:
bool Replace(Microsoft::VisualStudio::Text::Span replaceSpan, System::String ^ replaceWith);
public:
bool Replace(Microsoft::VisualStudio::Text::Span replaceSpan, Platform::String ^ replaceWith);
bool Replace(Microsoft::VisualStudio::Text::Span replaceSpan, std::wstring const & replaceWith);
public bool Replace (Microsoft.VisualStudio.Text.Span replaceSpan, string replaceWith);
abstract member Replace : Microsoft.VisualStudio.Text.Span * string -> bool
Public Function Replace (replaceSpan As Span, replaceWith As String) As Boolean
Parameters
- replaceSpan
- Span
The span of characters to replace.
- replaceWith
- String
The new text.
Returns
true
if the replacement succeeded, false
if it was prevented by a read-only region.
Exceptions
replaceSpan
.End is greater than the length of the buffer.
replaceWith
is null.
Remarks
Replacing an empty span with an empty string will succeed but will not generate a new snapshot or raise a Changed event.
Applies to
Replace(Int32, Int32, String)
Replaces a sequence of characters with different text. This method has the same effect as first deleting the
charsToReplace
and then inserting replaceWith
.
public:
bool Replace(int startPosition, int charsToReplace, System::String ^ replaceWith);
public:
bool Replace(int startPosition, int charsToReplace, Platform::String ^ replaceWith);
bool Replace(int startPosition, int charsToReplace, std::wstring const & replaceWith);
public bool Replace (int startPosition, int charsToReplace, string replaceWith);
abstract member Replace : int * int * string -> bool
Public Function Replace (startPosition As Integer, charsToReplace As Integer, replaceWith As String) As Boolean
Parameters
- startPosition
- Int32
The buffer position at which to start replacing.
- charsToReplace
- Int32
The number of characters to replace.
- replaceWith
- String
The new text.
Returns
true
if the replacement succeeded; false
if it was prevented by a read-only region.
Exceptions
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.
replaceWith
is null.
Remarks
Replacing zero characters with an empty string will succeed but will not generate a new snapshot or raise a Changed event.