SelectionEventArgs Class (2007 System)

Provides data for the SelectionChange, Selected, and Deselected events of a Bookmark control.

This API is not CLS-compliant. 

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

Syntax

'Declaration
<CLSCompliantAttribute(False)> _
<PermissionSetAttribute(SecurityAction.Demand, Name := "FullTrust")> _
Public Class SelectionEventArgs _
    Inherits EventArgs
'Usage
Dim instance As SelectionEventArgs
[CLSCompliantAttribute(false)]
[PermissionSetAttribute(SecurityAction.Demand, Name = "FullTrust")]
public class SelectionEventArgs : EventArgs
[CLSCompliantAttribute(false)]
[PermissionSetAttribute(SecurityAction::Demand, Name = L"FullTrust")]
public ref class SelectionEventArgs : public EventArgs
public class SelectionEventArgs extends EventArgs

Examples

The following code example adds a Bookmark control with text to the document and then creates a Selected event handler. A message box is displayed when you move the cursor into the bookmark.

This example is for a document-level customization.

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

Inheritance Hierarchy

System.Object
  System.EventArgs
    Microsoft.Office.Tools.Word.SelectionEventArgs

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

SelectionEventArgs Members

Microsoft.Office.Tools.Word Namespace