Compartilhar via


Método EditPoint2.Paste

Insere o conteúdo da área de transferência no local atual.

Namespace:  EnvDTE80
Assembly:  EnvDTE80 (em EnvDTE80.dll)

Sintaxe

'Declaração
Sub Paste
void Paste()
void Paste()
abstract Paste : unit -> unit 
function Paste()

Implementações

EditPoint.Paste()

Comentários

PasteMove o ponto de edição após a inserção.

Exemplos

Sub PasteExample(ByVal dte As DTE2)

    ' Create a new text file and insert ten lines of text.
    dte.ItemOperations.NewFile()
    Dim textDoc As TextDocument = _
        CType(dte.ActiveDocument.Object(), TextDocument)
    Dim editPnt As EditPoint = textDoc.StartPoint.CreateEditPoint()
    Dim i As Integer
    For i = 1 To 10
        editPnt.Insert("Line " & i.ToString() & vbCrLf)
    Next

    If MsgBox("Reverse the order of the lines?", MsgBoxStyle.YesNo) = _
        MsgBoxResult.Yes Then
        Dim textSel As TextSelection = textDoc.Selection

        ' Position insertion point at beginning of "Line 2".
        textSel.StartOfDocument()
        textSel.LineDown()

        ' Reverse the order of the lines by cutting "Line 2", 
        ' pasting it at the start of the document, and then cutting
        ' "Line 3" and pasting it at the start of the document,
        ' and so on.
        For i = 1 To 9
            textSel.LineDown(True)
            textSel.Cut()
            editPnt.StartOfDocument()
            editPnt.Paste()
        Next
    End If

End Sub
public void PasteExample(DTE2 dte)
{
    // Create a new text file and insert ten lines of text.
    dte.ItemOperations.NewFile(@"General\Text File", "", 
        Constants.vsViewKindPrimary);
    TextDocument textDoc = 
        (TextDocument)dte.ActiveDocument.Object("TextDocument");
    EditPoint editPnt = textDoc.StartPoint.CreateEditPoint();
    
    for (int i = 1; i <= 10; i++)
        editPnt.Insert("Line " + i.ToString() + "\n");

    if (MessageBox.Show("Reverse the order of the lines?", "", 
        MessageBoxButtons.YesNo) == DialogResult.Yes)
    {
        TextSelection textSel = textDoc.Selection;

        // Position insertion point at beginning of "Line 2".
        textSel.StartOfDocument(false);
        textSel.LineDown(false, 1);

        // Reverse the order of the lines by cutting "Line 2", 
        // pasting it at the start of the document,  and then cutting
        // "Line 3" and pasting it at the start of the document,
        // and so on.
        for (int i = 1; i <= 9; i++)
        {
            textSel.LineDown(true, 1);
            textSel.Cut();
            editPnt.StartOfDocument();
            editPnt.Paste();
        }
    }
}

Segurança do .NET Framework

Consulte também

Referência

EditPoint2 Interface

Sobrecargas Paste

Namespace EnvDTE80

Outros recursos

Como: compilar e Executar a automação de exemplos de Código do modelo de objeto