Share via


Bookmark View Controls

Microsoft Visual Studio Tools for the Microsoft Office System, Version 2.0 provides a number of view controls that enable you to program against events and bind data to objects such as ranges, lists, bookmarks and XML nodes. The Bookmark view control provides additional functionality that greatly enhances the bookmark object. If you're familiar with programming against bookmarks, then you know how difficult it can be to reuse the text assigned to a bookmark because the assignment causes the bookmark to be deleted from the collection. You have to recreate the bookmark whenever you've assigned any text. In Visual Studio Tools for Office, Version 2.0, you can assign text to the Bookmark.Text property, and doing so will not delete the bookmark! Note that this is different from assigning text to the Bookmark.Range.Text property. The following table describes some of the differences between native Word bookmarks and Bookmark view controls:

Native Bookmark Bookmark View Control
Assigning text to the bookmark Text is assigned and the bookmark is deleted. Text is assigned, but the bookmark is not deleted provided it was assigned to the Bookmark.Text property instead of the Bookmark.Range.Text property.
Assigning an empty string to the bookmark Text in the bookmark is deleted and the bookmark is deleted. Text in the bookmark is deleted and the bookmark becomes a zero-length bookmark.
Assigning text to a zero-length bookmark Text is appended to the right of the bookmark and the bookmark remains zero-length. Text is assigned to the bookmark and the bookmark expands to contain all of the text assigned.
Programming against bookmark events Not available. Bookmark view controls expose several events, such as BeforeDoubleClick, BeforeRightClick, Selected, Deselected, SelectionChange, and BindingContextChanged.
Binding data to a bookmark Not available. Bookmark view controls can be bound to data in the same way Windows Forms controls are bound to data.

--Kathleen McGrath
-----
This posting is provided "AS IS" with no warranties, and confers no rights.

Comments

  • Anonymous
    April 13, 2004
    Thank you! This is the way native bookmarks should have behaved to begin with. The existing behavior is simply counterintuitive.
  • Anonymous
    April 18, 2004
    Jay: You're not kidding! Wow, this is great stuff.

    Thanks, Kathleen, for summarizing this so concisely.