Bookmark.Deselected Event (2007 System)

Occurs when selection moves from the Bookmark control to an area outside of the Bookmark control.

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

Syntax

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

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

Remarks

This event is raised only when the Bookmark control has focus, and then focus is transferred away from the Bookmark control.

Examples

The following code example adds a Bookmark control with text to the first paragraph of the document and creates a Deselected event handler. A message box is displayed when the user moves the cursor from inside the bookmark to an area outside of the bookmark.

This example is for a document-level customization.

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

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

Private Sub BookmarkDeselect_Deselected(ByVal sender As Object, _
    ByVal e As Microsoft.Office.Tools.Word.SelectionEventArgs) _
    Handles BookmarkDeselect.Deselected
    MessageBox.Show("The selection has moved outside of the bookmark")
End Sub
Microsoft.Office.Tools.Word.Bookmark bookmarkDeselect;

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

void  bookmarkDeselect_Deselected(object sender, Microsoft.Office.Tools.Word.SelectionEventArgs e)
{
    MessageBox.Show("The selection has moved outside of the bookmark");
}

.NET Framework Security

See Also

Reference

Bookmark Class

Bookmark Members

Microsoft.Office.Tools.Word Namespace