Bookmark.Selected 事件
會在選取 Bookmark 控制項時發生。
命名空間: Microsoft.Office.Tools.Word
組件: Microsoft.Office.Tools.Word (在 Microsoft.Office.Tools.Word.dll 中)
語法
'宣告
Event Selected As SelectionEventHandler
event SelectionEventHandler Selected
備註
當選取範圍變更為 Bookmark 控制項時,便會引發這個事件。
範例
下列程式碼範例將有文字的 Bookmark 控制項加入至文件的第一個段落,然後建立 Selected 事件處理常式。 當游標移入書籤中時,便會顯示訊息方塊。
這是示範文件層級自訂的範例。
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.");
}
.NET Framework 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。