Udostępnij za pośrednictwem


Bookmark.SelectionChange Event (2007 System)

Occurs when the selection inside the Bookmark control changes.

Namespace:  Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word.v9.0 (in Microsoft.Office.Tools.Word.v9.0.dll)

Syntax

'Declaration
Public Event SelectionChange As SelectionEventHandler
'Usage
Dim instance As Bookmark 
Dim handler As SelectionEventHandler 

AddHandler instance.SelectionChange, handler
public event SelectionEventHandler SelectionChange
public:
 event SelectionEventHandler^ SelectionChange {
    void add (SelectionEventHandler^ value);
    void remove (SelectionEventHandler^ value);
}
JScript does not support events.

Remarks

This event is raised when the selection changes to or within the Bookmark control.

Examples

The following code example adds a Bookmark control with text to the document and then creates a SelectionChange event handler. A message box is displayed when the cursor is moved within the bookmark.

This example is for a document-level customization.

WithEvents Bookmark5 As Microsoft.Office.Tools.Word.Bookmark

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

Private Sub Bookmark5_SelectionChange(ByVal sender As Object, _
    ByVal e As Microsoft.Office.Tools.Word.SelectionEventArgs) _
    Handles Bookmark5.SelectionChange
    MessageBox.Show("The selection has changed within Bookmark1.")
End Sub
Microsoft.Office.Tools.Word.Bookmark bookmark5;

private void BookmarkSelectionChange()
{
    this.Paragraphs[1].Range.InsertParagraphBefore();
    bookmark5 = this.Controls.AddBookmark(this.Paragraphs[1]
        .Range, "bookmark5");
    bookmark5.Text = "This is a sample bookmark.";
    bookmark5.SelectionChange += new Microsoft.Office.Tools.Word.SelectionEventHandler(bookmark5_SelectionChange);
}

void bookmark5_SelectionChange(object sender, Microsoft.Office.Tools.Word.SelectionEventArgs e)
{
    MessageBox.Show("The selection has changed within bookmark1.");
}

.NET Framework Security

See Also

Reference

Bookmark Class

Bookmark Members

Microsoft.Office.Tools.Word Namespace