DocumentBase.SelectionChange 事件

定义

在文档窗口中的选定内容发生更改时发生。

public event Microsoft.Office.Tools.Word.SelectionEventHandler SelectionChange;

事件类型

SelectionEventHandler

示例

下面的代码示例显示一条消息,指示每当你更改文档中的选定内容时,所选内容已更改。 若要使用此示例,请在 ThisDocument 文档级项目的类中运行它。

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.");
}
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

适用于