Represents a list box form field in a PDF document. List boxes display a scrollable list of options for selection.
using Nutrient;Inherits from: PdfFormField
The SDK creates this class through factory methods or other SDK objects.
Properties
HasSelection
public bool HasSelection { get; }Whether the list box has a value selected.
Type: bool
ItemCount
public int ItemCount { get; }The number of items in the list box.
Type: int
SelectedValue
public string SelectedValue { get; set; }The currently selected value. For multi-select list boxes, this returns the first selected value.
Type: string
Methods
AddItem
public void AddItem(string text)Adds an item to the list box.
Parameters
| Name | Type | Description |
|---|---|---|
text | string | The display text for the item. |
Throws: NutrientException - Thrown when the operation fails.
public void AddItem(string text, string value)Adds an item to the list box with a separate export value.
Parameters
| Name | Type | Description |
|---|---|---|
text | string | The display text for the item. |
value | string | The export value for the item. |
Throws: NutrientException - Thrown when the operation fails.
RemoveItemAt
public void RemoveItemAt(int index)Removes an item from the list box at the specified index.
Parameters
| Name | Type | Description |
|---|---|---|
index | int | The 0-based index of the item to remove. |
Throws: NutrientException - Thrown when index is out of range.
Throws: NutrientException - Thrown when the operation fails.
Resource management
public void Dispose()PdfListBoxField implements IDisposable. Call Dispose() or use a C# using declaration to release its native handle right away. If you don’t, the handle is released when the object is garbage collected.