locked
Rich text content control with text box : ContentControlOnEnter & ContentControlOnExit events did not fire. RRS feed

  • Question

  • Hi. everyone. I'm jeon.

     

    Recently, on working with VSTO SE,  i have encountered a problem which ContentControlOnEnter and ContentControlOnExit event did not fire.

     

    This is the procedure i did.

     

    1. In word add-in, i attached all content control event handlers.

    2. Opened a new document.

    3. Inserted a rich text content control into the document pane.

    4. Added a normal text box into the rich text content control.

    5. Moved the cursor from outside the rich content control into the text box.

       In this step, I expected the ContentControlOnEnter event fired, but it didn't.

    6. Moved the cursor from inside the text box into another place in the document.

       In this step, I expected the ContentControlOnExit event fired, but it didn't.

     

    Are these the known bugs?

     

    Thanks in advance.

     

     

     

     

     

    Friday, June 20, 2008 5:23 AM

Answers

  • Hi Jeon

     

    By "normal text box" I'm assuming you mean the kind inserted using the Drawing tools (Insert/Illustration in Word 2007) and not a WinForm, form field or ActiveX field with the same designation.

     

    If that is the case, I'm not sure whether the Word team would describe this as a "bug" or "by design".

     

    The problem is that all objects in the Shapes collection don't reside in the text flow of the main document body. They're in a different "layer", with an anchor to the text flow. So Word doesn't really "see" them. Another example of this in many versions of Word is Captions for Shapes. These are also in text boxes and Word doesn't pick them up for Tables of Figures. (Although I think this particular problem has finally been solved in 2007 after ten years.)

     

    By the same token, moving into a Shape that's anchored in a content control won't trigger the content control events.

     

    Depending on what you want to use the text box for, a useful alternative might be to convert it to a Frame (in the "Text box" tab of the "Formatting" dialog box). Or you could possibly use a 1-cell table with text wrap formatting activated.

    Friday, June 20, 2008 9:24 AM

All replies

  • Hi Jeon

     

    By "normal text box" I'm assuming you mean the kind inserted using the Drawing tools (Insert/Illustration in Word 2007) and not a WinForm, form field or ActiveX field with the same designation.

     

    If that is the case, I'm not sure whether the Word team would describe this as a "bug" or "by design".

     

    The problem is that all objects in the Shapes collection don't reside in the text flow of the main document body. They're in a different "layer", with an anchor to the text flow. So Word doesn't really "see" them. Another example of this in many versions of Word is Captions for Shapes. These are also in text boxes and Word doesn't pick them up for Tables of Figures. (Although I think this particular problem has finally been solved in 2007 after ten years.)

     

    By the same token, moving into a Shape that's anchored in a content control won't trigger the content control events.

     

    Depending on what you want to use the text box for, a useful alternative might be to convert it to a Frame (in the "Text box" tab of the "Formatting" dialog box). Or you could possibly use a 1-cell table with text wrap formatting activated.

    Friday, June 20, 2008 9:24 AM
  • Hi. Cindy.

     

    Thanks for your very valuable answer and recommendation for alternatives.

    Now, i have completely understood this problem.

     

    Jeon.

    Friday, June 20, 2008 10:17 AM