SelectionEventArgs 接口

定义

提供有关 Bookmark 控件的 SelectionChangeSelectedDeselected 事件的数据。

[System.Runtime.InteropServices.Guid("1669c37b-2ce5-4924-ac10-2e50a5b95901")]
public interface SelectionEventArgs
属性

示例

下面的代码示例将 Bookmark 包含文本的控件添加到文档中,然后创建一个 Selected 事件处理程序。 将光标移到书签中时,将显示一个消息框。

此示例适用于文档级自定义项。

Microsoft.Office.Tools.Word.Bookmark bookmark4;
        
private void BookmarkSelected()
{
    this.Paragraphs[1].Range.InsertParagraphBefore();
    bookmark4 = this.Controls.AddBookmark(this.Paragraphs[1]
        .Range, "bookmark4");
    bookmark4.Text = "This is a sample bookmark.";
    bookmark4.Selected += new Microsoft.Office.Tools
        .Word.SelectionEventHandler(bookmark4_Selected);
}

void bookmark4_Selected(object sender, Microsoft.Office.Tools
    .Word.SelectionEventArgs e)
{
    MessageBox.Show("The selection has moved to bookmark1.");
}
WithEvents Bookmark4 As Microsoft.Office.Tools.Word.Bookmark

Private Sub BookmarkSelected()
    Me.Paragraphs(1).Range.InsertParagraphBefore()
    Bookmark4 = Me.Controls.AddBookmark(Me.Paragraphs(1).Range, _
        "Bookmark4")
    Bookmark4.Text = "This is a sample bookmark."
End Sub

Private Sub Bookmark4_Selected(ByVal sender As Object, _
    ByVal e As Microsoft.Office.Tools.Word.SelectionEventArgs) _
    Handles Bookmark4.Selected
    MessageBox.Show("The selection has moved to Bookmark1.")
End Sub

属性

Selection

获取表示所选文本的 Selection

适用于