ITextBuffer.Insert(Int32, String) 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.
Inserts the given text
at the specified position
in 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.