Table of Contents

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

value string

The new value.

Remarks

  • Check box — value is parsed as a boolean; the stored state and the painted symbol are both updated.
  • Drop-down list — value must 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 — value is parsed with InvariantCulture; both w:fullDate and 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

value is null.

ContentControlEditException

The value is not valid for the control's kind, or the preserved markup could not be rewritten.