ITextEdit.Replace 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
重载
| Replace(Span, String) |
用不同的文本替换字符序列。 此方法与首先删除中的字符和插入的效果相同 |
| Replace(Int32, Int32, String) |
用不同的文本替换字符序列。 此方法与首先删除然后插入的效果相同 |
Replace(Span, String)
用不同的文本替换字符序列。 此方法与首先删除中的字符和插入的效果相同 replaceSpan 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
参数
- replaceSpan
- Span
要替换的字符的范围。
- replaceWith
- String
新文本。
返回
如果替换成功,则为 true ; 如果被只读区域阻止,则为false 。
例外
replaceSpan.End 大于缓冲区的长度。
replaceWith为 null。
注解
用空字符串替换空的范围将会成功,但不会生成新的快照,也不会引发 Changed 事件。
适用于
Replace(Int32, Int32, String)
用不同的文本替换字符序列。 此方法与首先删除然后插入的效果相同 charsToReplace 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
参数
- startPosition
- Int32
开始替换的缓冲区位置。
- charsToReplace
- Int32
要替换的字符数。
- replaceWith
- String
新文本。
返回
如果替换成功,则为 true ;如果被只读区域阻止,则为 false 。
例外
startPosition小于零或大于缓冲区的长度,或 charsToReplace 小于零,或者 startPosition + charsToReplace 大于缓冲区的长度值。
replaceWith为 null。
注解
将零个字符替换为空字符串将会成功,但不会生成新的快照或引发 Changed 事件。