Udostępnij za pośrednictwem


ITextBuffer.Insert(Int32, String) Method

Definition

Inserts the given textat the specified positionin the ITextBuffer.

public:
 Microsoft::VisualStudio::Text::ITextSnapshot ^ Insert(int position, System::String ^ text);
public:
 Microsoft::VisualStudio::Text::ITextSnapshot ^ Insert(int position, Platform::String ^ text);
Microsoft::VisualStudio::Text::ITextSnapshot Insert(int position, std::wstring const & text);
public Microsoft.VisualStudio.Text.ITextSnapshot Insert (int position, string text);
abstract member Insert : int * string -> Microsoft.VisualStudio.Text.ITextSnapshot
Public Function Insert (position As Integer, text As String) As ITextSnapshot

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