ITextBuffer.Insert(Int32, String) Method

Definition

Inserts the given textat the specified positionin the ITextBuffer.

C++/CX
public:
 Microsoft::VisualStudio::Text::ITextSnapshot ^ Insert(int position, Platform::String ^ text);

Parameters

position
Int32

The buffer position at which the first character of the text will appear.

text
String

The text to be inserted.

Returns

The ITextSnapshot.

Exceptions

position is less than zero or greater than the length of the buffer.

text is null.

A text edit is currently active, or CheckEditAccess() would return false.

Remarks

This is a shortcut for creating a new ITextEdit object, using it to insert the text, and then applying it. If the insertion fails on account of a read-only region, the snapshot returned will be the same as the current snapshot of the buffer before the attempted insertion.

Applies to

Product Versions
Visual Studio SDK 2015, 2017, 2019, 2022