none
Whats with {CONTROL WinForms.Control.Host.V3 \s} RRS feed

  • Question

  • I am curious about how to make form controls look better on a document surface.  The following code and variations on it can add various Form Controls to the document:

     

    Document extendedDocument = Globals.Factory.GetVstoObject(this.Application.ActiveDocument);
    
    extendedDocument.Paragraphs[1].Range.InsertParagraphAfter();
    Microsoft.Office.Tools.Word.Controls.Button aButton = extendedDocument.Controls.AddButton(extendedDocument.Paragraphs.Last.Range, 32, 32, "salesButton");
    aButton.Tag = "Button";
    aButton.Image = AWordPlugin.Properties.Resources.anImage32x32;
    
    

     

    However it always leaves "{CONTROL WinForms.Control.Host.V3 \s}" at the insertion point.  You can delete everything but the brackets it looks like and then maybe color the brackets white or whatever to match the document color so it mostly disappears.  This still leaves them showing when you click the control.

    Am I doing this wrong?  How does one go about assembling a bunch of these in a nice layout without weird effects? (Trying to change their location through the Top, Left, Bottom and Right properties throws an error.)

    Monday, August 8, 2011 10:23 AM

Answers

  • Hi Azethoth

    What you're seeing is the field code for the ActiveX control that VSTO places in the document. The ActiveX control "wraps" the WinForms control so that Word (or Excel) can deal with it. Natively, the office apps have no idea what .NET controls are, so they have to be wrapped up in something Office does understand.

    Press Alt+F9 to toggle the field code display to the field result display :-)


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by Azethoth Monday, August 8, 2011 8:28 PM
    Monday, August 8, 2011 10:49 AM
    Moderator