Bookmark.Deselected 事件 (2007 系統)
更新:2007 年 11 月
會在選取範圍從 Bookmark 控制項移至 Bookmark 控制項以外的區域時發生。
命名空間: Microsoft.Office.Tools.Word
組件: Microsoft.Office.Tools.Word.v9.0 (在 Microsoft.Office.Tools.Word.v9.0.dll 中)
語法
Public Event Deselected As SelectionEventHandler
Dim instance As Bookmark
Dim handler As SelectionEventHandler
AddHandler instance.Deselected, handler
public event SelectionEventHandler Deselected
備註
只有在 Bookmark 控制項擁有焦點,而焦點又接著從 Bookmark 控制項移開時,才會引發這個事件。
範例
下列程式碼範例將有文字的 Bookmark 控制項加入至文件的第一個段落,並且建立 Deselected 事件處理常式。當使用者將游標從書籤內部移出至書籤以外的區域,便會顯示訊息方塊。
這是示範文件層級自訂的範例。
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");
}
使用權限
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。