Method SetValue
- Namespace
- DocWright.Dom.ContentControls
- Assembly
- DocWright.Dom.dll
SetValue(string)
Sets the control's value, updating both the displayed content and any stored representation the kind keeps.
public void SetValue(string value)
Parameters
valuestringThe new value.
Remarks
- Check box —
valueis parsed as a boolean; the stored state and the painted symbol are both updated. - Drop-down list —
valuemust match an entry's value or its display text, because Word does not allow anything else; the entry's display text becomes the content. - Combo box — a matching entry is used when there is one, and free text is accepted when there is not.
- Date picker —
valueis parsed with InvariantCulture; bothw:fullDateand the displayed text are updated. Use SetDate(DateTimeOffset, CultureInfo?) to avoid the parse. - Every other kind — the content becomes a single run
carrying
value.
Setting a value clears w:showingPlcHdr, which is what Word does the
moment a control receives content.
Exceptions
- ArgumentNullException
valueis null.- ContentControlEditException
The value is not valid for the control's kind, or the preserved markup could not be rewritten.