PdfChoiceField Class

A choice field (ISO 32000-2, 12.7.5.4): a list box or a combo box.

public sealed class PdfChoiceField : PdfFormField
Inheritance
PdfFormField PdfChoiceField

Properties

NameDescription
IsComboBoxGets a value indicating whether the field is a combo box, a drop-down list (bit 18 of PdfFormField.Flags); otherwise it is a list box.
IsEditableGets a value indicating whether a combo box also accepts a text that is not an option (bit 19 of PdfFormField.Flags).
IsMultiSelectGets a value indicating whether several options can be chosen (bit 22 of PdfFormField.Flags).
OptionsGets the options (/Opt, inherited).
SelectedValuesGets the chosen values: the value (/V), a text or an array of texts.
ValueGets or sets the chosen value, or the first of them; setting it writes the appearances of the widgets.

Gets a value indicating whether the field is a combo box, a drop-down list (bit 18 of PdfFormField.Flags); otherwise it is a list box.

public bool IsComboBox { get; }

Property value

bool

Gets a value indicating whether a combo box also accepts a text that is not an option (bit 19 of PdfFormField.Flags).

public bool IsEditable { get; }

Property value

bool

IsMultiSelect

PdfChoiceField.cs

Gets a value indicating whether several options can be chosen (bit 22 of PdfFormField.Flags).

public bool IsMultiSelect { get; }

Property value

bool

Gets the options (/Opt, inherited).

public IReadOnlyList<PdfChoiceOption> Options { get; }

SelectedValues

PdfChoiceField.cs

Gets the chosen values: the value (/V), a text or an array of texts.

public IReadOnlyList<string> SelectedValues { get; }

Property value

IReadOnlyList<string>

Gets or sets the chosen value, or the first of them; setting it writes the appearances of the widgets.

public override string? Value { get; set; }

Property value

string?

Exceptions

ArgumentException
The value is not an option, and the field is not an editable combo box.
InvalidOperationException
The field is read-only.

Methods

NameDescription
SetSelectedValues(IEnumerable<string>)Chooses values: the value (/V), the indexes of the options (/I) and the appearances of the widgets are written.

SetSelectedValues(IEnumerable<string>)

PdfChoiceField.cs

Chooses values: the value (/V), the indexes of the options (/I) and the appearances of the widgets are written.

public void SetSelectedValues(IEnumerable<string> values)

Parameters

values IEnumerable<string>
The values: the export values of options, or a text for an editable combo box.

Exceptions

ArgumentException
A value is not an option and the field is not an editable combo box, or several values are given to a field that is not multi-select.
InvalidOperationException
The field is read-only.