Condividi tramite


ITextBuffer.Insert Method

Inserts the given text at the specified position in the ITextBuffer.

Namespace:  Microsoft.VisualStudio.Text
Assembly:  Microsoft.VisualStudio.Text.Data (in Microsoft.VisualStudio.Text.Data.dll)

Syntax

'Dichiarazione
Function Insert ( _
    position As Integer, _
    text As String _
) As ITextSnapshot
ITextSnapshot Insert(
    int position,
    string text
)
ITextSnapshot^ Insert(
    int position, 
    String^ text
)
abstract Insert : 
        position:int * 
        text:string -> ITextSnapshot 
function Insert(
    position : int, 
    text : String
) : ITextSnapshot

Parameters

  • position
    Type: System.Int32
    The buffer position at which the first character of the text will appear.

Return Value

Type: Microsoft.VisualStudio.Text.ITextSnapshot
The ITextSnapshot.

Exceptions

Exception Condition
ArgumentNullException

text is nulla null reference (Nothing in Visual Basic).

InvalidOperationException

A text edit is currently active.

ArgumentOutOfRangeException

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

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.

.NET Framework Security

See Also

Reference

ITextBuffer Interface

Microsoft.VisualStudio.Text Namespace