Evento Document.SelectionChange

Viene generato quando cambia la selezione nella finestra del documento.

Spazio dei nomi:  Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word (in Microsoft.Office.Tools.Word.dll)

Sintassi

'Dichiarazione
Event SelectionChange As SelectionEventHandler
event SelectionEventHandler SelectionChange

Esempi

Nell'esempio di codice riportato di seguito viene illustrato come visualizzare un messaggio che indica che la selezione è cambiata ogni volta che si cambia la selezione all'interno del documento. Questo esempio è valido per un componente aggiuntivo a livello di applicazione.

Private Sub DocumentSelectionChange()
    Dim vstoDoc As Document = Globals.Factory.GetVstoObject(Me.Application.ActiveDocument)
    AddHandler vstoDoc.SelectionChange, AddressOf ThisDocument_SelectionChange
End Sub

Private Sub ThisDocument_SelectionChange(ByVal sender As Object, ByVal e As Microsoft.Office. _
    Tools.Word.SelectionEventArgs)
    System.Windows.Forms.MessageBox.Show("The selection in the document has changed.")
End Sub
private void DocumentSelectionChange()
{
    Document vstoDoc = Globals.Factory.GetVstoObject(this.Application.ActiveDocument);
    vstoDoc.SelectionChange += new Microsoft.Office.Tools.Word.SelectionEventHandler(ThisDocument_SelectionChange);
}

void ThisDocument_SelectionChange(object sender, Microsoft.Office.Tools.Word.SelectionEventArgs e)
{
    System.Windows.Forms.MessageBox.Show("The selection in the document has changed.");
}

Sicurezza di .NET Framework

Vedere anche

Riferimenti

Document Interfaccia

Spazio dei nomi Microsoft.Office.Tools.Word