DocumentBase.SelectionChange 事件

當文件視窗中的選取範圍變更時發生。

命名空間:  Microsoft.Office.Tools.Word
組件:  Microsoft.Office.Tools.Word.v4.0.Utilities (在 Microsoft.Office.Tools.Word.v4.0.Utilities.dll 中)

語法

'宣告
Public Event SelectionChange As SelectionEventHandler
public event SelectionEventHandler SelectionChange

範例

每當您在文件中變更選取範圍時,下列程式碼範例就會顯示訊息,指出選取範圍已變更。 若要使用這個範例,請在文件層級專案中的 ThisDocument 類別執行。

Private Sub DocumentSelectionChange()
    AddHandler Me.SelectionChange, AddressOf ThisDocument_SelectionChange
End Sub

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

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

.NET Framework 安全性

請參閱

參考

DocumentBase 類別

Microsoft.Office.Tools.Word 命名空間