Create input fields in Word. C#
How do you
add an input field from the developer tools in Word at runtime?
The real
form fields in Word from the Developer Tools area are of type ContentControl.
These
differ from the pure TextInputFields in that you can format the input fields
and adjust the color.
In C # at
runtime, programmatically
The actual
add comes with Word.Document.ContentControls.Add (inputtype, destination)
_doc.ContentControls.Add(wdContentControlText, _app.Selection.Range)
|
In C #,
interop, vsto:
ContentControl textField = _doc.ContentControls.Add(WdContentControlType.wdContentControlText, _app.Selection.Range);
|
Subject:
Programming
in vba, C #
Word
ContentControl
You can
find the developer input fields under Word Menu-> Developer Tools->
Controls-> Aa (Text Only Content Control)
Example of use:
Here a real
input field is added behind each photo.
If an entry
has been made, the field appears as text
If the
field receives the focus, the field is grayed out.
If no entry
takes place, then the place can be displayed as an empty line or be marked in
color.
C # input
code, vsto in the example
Here a real
input field is added behind each photo.
If an entry
has been made, the field appears as text
//< add formfield field >
act_Image_Range.InsertAfter("\n");
_app.Selection.Start=act_Image_Range.End;
ContentControl textField = _doc.ContentControls.Add(WdContentControlType.wdContentControlText, _app.Selection.Range);
textField.Title = "Bild-Text";
textField.MultiLine = true;
textField.LockContentControl = true;
textField.Appearance = WdContentControlAppearance.wdContentControlHidden;
textField.SetPlaceholderText(Text:" ");
//</ add formfield field >
|
In C #,
Visual Studio Vsto interop com