End Sub Context Enter

The ContextEnter event handler enables you to take action when you enter the context of an XMLNode control. For example, you might want to display a control on the actions pane when a user moves the cursor into the context of an XMLNode control. The context is the entire area that an XMLNode covers (from its starting tag to its ending tag), including any child nodes. Entering the context occurs whenever the cursor moves into this area from outside the area. The ContextEnter event differs from the Selection event of the XMLNode. If you enter the child nodes of the XMLNode, you will still raise the ContextEnter event because child nodes are within the context of their parent nodes. However, if you move from one area within the context of an XMLNode to another area within the same context (for example, from one child node to another child node), the ContextEnter event is not raised. Listing 6.30 demonstrates.

Listing 6.30. Adding a MonthCalendar control to the actions pane when the context of an XMLNode is entered

Dim calendar As Windows.Forms.Control

Private Sub SampleNameNode_ContextEnter(ByVal sender As _ Object, ByVal e As Microsoft.Office.Tools.Word _ .ContextChangeEventArgs) Handles _ SampleNameNode.ContextEnter

Calendar = New MonthCalendar Me.ActionsPane.Controls.Add(calendar)

When you move your cursor into the context of the Name node (perhaps by entering any area of the Name node, including the FirstName node or the LastName node), the MonthCalendar control is added to the actions pane.

0 0

Post a comment