Table of Contents

Class PdfListFieldItemCollection

Namespace
Syncfusion.Pdf.Interactive
Assembly
Syncfusion.Pdf.Portable.dll

Represents list field item collection.

public class PdfListFieldItemCollection : PdfCollection, IEnumerable
Inheritance
PdfListFieldItemCollection
Implements
Inherited Members

Examples

//Create a new PDf document
PdfDocument document = new PdfDocument();           
//Creates a new page and adds it as the last page of the document
PdfPage page = document.Pages.Add();                         
//Create list box
PdfListBoxField listBox = new PdfListBoxField(page, "list1");
//Add the field to listbox.
document.Form.Fields.Add(listBox);            
//Set the properties.
listBox.Bounds = new RectangleF(100, 350, 100, 50);
listBox.HighlightMode = PdfHighlightMode.Outline;            
// Creates list items
PdfListFieldItemCollection itemCollection = listBox.Items;
//Add the items to the list box
itemCollection.Add(new PdfListFieldItem("English", "English"));
itemCollection.Add(new PdfListFieldItem("French", "French"));
itemCollection.Add(new PdfListFieldItem("German", "German"));
listBox.SelectedIndex = 0;            
document.Save("Form.pdf");
document.Close(true);
'Create a new PDf document
Dim document As PdfDocument = New PdfDocument()
'Create a page
Dim page As PdfPage = document.Pages.Add()
'Create list box
Dim listBox As PdfListBoxField = New PdfListBoxField(page, "list1")
'Add the field to listbox.
document.Form.Fields.Add(listBox)
'Set the properties.
listBox.Bounds = New RectangleF(100, 350, 100, 50)
listBox.HighlightMode = PdfHighlightMode.Outline
' Creates list items
Dim itemCollection As PdfListFieldItemCollection = listBox.Items
'Add the items to the list box
itemCollection.Add(New PdfListFieldItem("English", "English"))
itemCollection.Add(New PdfListFieldItem("French", "French"))
itemCollection.Add(New PdfListFieldItem("German", "German"))
listBox.SelectedIndex = 0
document.Save("Form.pdf")
document.Close(True)

Remarks

This PdfListFieldItemCollection class is used to get the collection of list field items in PDF forms. Please refer the UG docuemntation link for more details

Constructors

PdfListFieldItemCollection()

Initializes a new instance of the PdfListFieldItemCollection class.

public PdfListFieldItemCollection()

Examples

//Create a new PDf document
PdfDocument document = new PdfDocument();           
//Creates a new page and adds it as the last page of the document
PdfPage page = document.Pages.Add();                         
//Create list box
PdfListBoxField listBox = new PdfListBoxField(page, "list1");
//Add the field to listbox.
document.Form.Fields.Add(listBox);            
//Set the properties.
listBox.Bounds = new RectangleF(100, 350, 100, 50);
listBox.HighlightMode = PdfHighlightMode.Outline;            
// Creates list items
PdfListFieldItemCollection itemCollection = new PdfListFieldItemCollection();
itemCollection = listBox.Items;
//Add the items to the list box
itemCollection.Add(new PdfListFieldItem("English", "English"));
itemCollection.Add(new PdfListFieldItem("French", "French"));
itemCollection.Add(new PdfListFieldItem("German", "German"));
listBox.SelectedIndex = 0;            
document.Save("Form.pdf");
document.Close(true);
'Create a new PDf document
Dim document As PdfDocument = New PdfDocument()
'Create a page
Dim page As PdfPage = document.Pages.Add()
'Create list box
Dim listBox As PdfListBoxField = New PdfListBoxField(page, "list1")
'Add the field to listbox.
document.Form.Fields.Add(listBox)
'Set the properties.
listBox.Bounds = New RectangleF(100, 350, 100, 50)
listBox.HighlightMode = PdfHighlightMode.Outline
' Creates list items
Dim itemCollection As PdfListFieldItemCollection = New PdfListFieldItemCollection()
itemCollection = listBox.Items
'Add the items to the list box
itemCollection.Add(New PdfListFieldItem("English", "English"))
itemCollection.Add(New PdfListFieldItem("French", "French"))
itemCollection.Add(New PdfListFieldItem("German", "German"))
listBox.SelectedIndex = 0
document.Save("Form.pdf")
document.Close(True)
See Also

Properties

this[int]

Gets the PdfListFieldItem at the specified index.[Read-Only]

public PdfListFieldItem this[int index] { get; }

Parameters

index int

Property Value

PdfListFieldItem

The PdfListFieldItem object.

Examples

//Create a new PDf document
PdfDocument document = new PdfDocument();           
//Creates a new page and adds it as the last page of the document
PdfPage page = document.Pages.Add();                       
PdfFont font = new PdfStandardFont(PdfFontFamily.Courier, 12f);
//Create list box
PdfListBoxField listBox = new PdfListBoxField(page, "list1");
//Add the field to listbox.
document.Form.Fields.Add(listBox);            
//Set the properties.
listBox.Bounds = new RectangleF(100, 350, 100, 50);
listBox.HighlightMode = PdfHighlightMode.Outline;            
// Creates list items
PdfListFieldItemCollection itemCollection = listBox.Items;
//Add the items to the list box
itemCollection.Add(new PdfListFieldItem("English", "English"));
itemCollection.Add(new PdfListFieldItem("French", "French"));
itemCollection.Add(new PdfListFieldItem("German", "German"));
// Reading the second item in the collection and assigning new values
PdfListFieldItem item = itemCollection[1];
item.Text = "Arabic";
item.Value = "Arabic";
listBox.SelectedIndex = 0;            
document.Save("Form.pdf");
document.Close(true);
'Create a new PDf document
Dim document As PdfDocument = New PdfDocument()
'Create a page
Dim page As PdfPage = document.Pages.Add()
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Courier, 12f)
'Create list box
Dim listBox As PdfListBoxField = New PdfListBoxField(page, "list1")
'Add the field to listbox.
document.Form.Fields.Add(listBox)
'Set the properties.
listBox.Bounds = New RectangleF(100, 350, 100, 50)
listBox.HighlightMode = PdfHighlightMode.Outline
' Creates list items
Dim itemCollection As PdfListFieldItemCollection = listBox.Items
'Add the items to the list box
itemCollection.Add(New PdfListFieldItem("English", "English"))
itemCollection.Add(New PdfListFieldItem("French", "French"))
itemCollection.Add(New PdfListFieldItem("German", "German"))
' Reading the second item in the collection and assigning new values
Dim item As PdfListFieldItem = itemCollection(1)
item.Text = "Arabic"
item.Value = "Arabic"
listBox.SelectedIndex = 0
document.Save("Form.pdf")
document.Close(True)
See Also

Methods

Add(PdfListFieldItem)

Adds the specified item in the collection.

public int Add(PdfListFieldItem item)

Parameters

item PdfListFieldItem

The PdfListFieldItem object which to be added in the collection.

Returns

int

item

Examples

//Create a new PDf document
PdfDocument document = new PdfDocument();           
//Creates a new page and adds it as the last page of the document
PdfPage page = document.Pages.Add();    
//Create list box
PdfListBoxField listBox = new PdfListBoxField(page, "list1");
//Add the field to listbox.
document.Form.Fields.Add(listBox);            
//Set the properties.
listBox.Bounds = new RectangleF(100, 350, 100, 50);
listBox.HighlightMode = PdfHighlightMode.Outline;            
// Creates list items
PdfListFieldItemCollection itemCollection = listBox.Items;
//Add the items to the list box
itemCollection.Add(new PdfListFieldItem("English", "English"));
itemCollection.Add(new PdfListFieldItem("French", "French"));
itemCollection.Add(new PdfListFieldItem("German", "German"));
document.Save("Form.pdf");
document.Close(true);
'Create a new PDf document
Dim document As PdfDocument = New PdfDocument()
'Create a page
Dim page As PdfPage = document.Pages.Add()
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Courier, 12f)
'Create list box
Dim listBox As PdfListBoxField = New PdfListBoxField(page, "list1")
'Add the field to listbox.
document.Form.Fields.Add(listBox)
'Set the properties.
listBox.Bounds = New RectangleF(100, 350, 100, 50)
listBox.HighlightMode = PdfHighlightMode.Outline
' Creates list items
Dim itemCollection As PdfListFieldItemCollection = listBox.Items
'Add the items to the list box
itemCollection.Add(New PdfListFieldItem("English", "English"))
itemCollection.Add(New PdfListFieldItem("French", "French"))
itemCollection.Add(New PdfListFieldItem("German", "German"))
document.Save("Form.pdf")
document.Close(True)
See Also

Clear()

Clears the collection.

public void Clear()

Examples

//Create a new PDf document
PdfDocument document = new PdfDocument();           
//Creates a new page and adds it as the last page of the document
PdfPage page = document.Pages.Add();   
//Create list box
PdfListBoxField listBox = new PdfListBoxField(page, "list1");
//Add the field to listbox.
document.Form.Fields.Add(listBox);            
//Set the properties.
listBox.Bounds = new RectangleF(100, 350, 100, 50);            
// Creates list items
PdfListFieldItemCollection itemCollection = listBox.Items;
//Add the items to the list box            
PdfListFieldItem item = new PdfListFieldItem("English", "English");
itemCollection.Add(item);
itemCollection.Add(new PdfListFieldItem("French", "French"));
itemCollection.Add(new PdfListFieldItem("German", "German"));
// Clear the collection
itemCollection.Clear();
document.Save("Form.pdf");
document.Close(true);
'Create a new PDf document
Dim document As PdfDocument = New PdfDocument()
'Create a page
Dim page As PdfPage = document.Pages.Add()
'Create list box
Dim listBox As PdfListBoxField = New PdfListBoxField(page, "list1")
'Add the field to listbox.
document.Form.Fields.Add(listBox)
'Set the properties.
listBox.Bounds = New RectangleF(100, 350, 100, 50)
' Creates list items
Dim itemCollection As PdfListFieldItemCollection = listBox.Items
'Add the items to the list box            
Dim item As PdfListFieldItem = New PdfListFieldItem("English", "English")
itemCollection.Add(item)
itemCollection.Add(New PdfListFieldItem("French", "French"))
itemCollection.Add(New PdfListFieldItem("German", "German"))
' Clear the collection
itemCollection.Clear()
document.Save("Form.pdf")
document.Close(True)
See Also

Contains(PdfListFieldItem)

Determines whether the item is present in the collection.

public bool Contains(PdfListFieldItem item)

Parameters

item PdfListFieldItem

Check whether PdfListFieldItem object is exists in the collection or not.

Returns

bool

true if the item is contained within the collection; otherwise, false.

Examples

//Create a new PDf document
PdfDocument document = new PdfDocument();           
//Creates a new page and adds it as the last page of the document
PdfPage page = document.Pages.Add();   
//Create list box
PdfListBoxField listBox = new PdfListBoxField(page, "list1");
//Add the field to listbox.
document.Form.Fields.Add(listBox);            
//Set the properties.
listBox.Bounds = new RectangleF(100, 350, 100, 50);            
// Creates list items
PdfListFieldItemCollection itemCollection = listBox.Items;
//Add the items to the list box            
PdfListFieldItem item = new PdfListFieldItem("English", "English");
itemCollection.Add(item);
itemCollection.Add(new PdfListFieldItem("French", "French"));
itemCollection.Add(new PdfListFieldItem("German", "German"));
if (itemCollection.Contains(item))
 MessageBox.Show("Already, item has added!");
else
 itemCollection.Add(item);
document.Save("Form.pdf");
document.Close(true);
'Create a new PDf document
Dim document As PdfDocument = New PdfDocument()
'Create a page
Dim page As PdfPage = document.Pages.Add()
'Create list box
Dim listBox As PdfListBoxField = New PdfListBoxField(page, "list1")
'Add the field to listbox.
document.Form.Fields.Add(listBox)
'Set the properties.
listBox.Bounds = New RectangleF(100, 350, 100, 50)
' Creates list items
Dim itemCollection As PdfListFieldItemCollection = listBox.Items
'Add the items to the list box            
Dim item As PdfListFieldItem = New PdfListFieldItem("English", "English")
itemCollection.Add(item)
itemCollection.Add(New PdfListFieldItem("French", "French"))
itemCollection.Add(New PdfListFieldItem("German", "German"))
If itemCollection.Contains(item) Then
 MessageBox.Show("Already, item has added!")
Else
 itemCollection.Add(item)
End If
document.Save("Form.pdf")
document.Close(True)
See Also

IndexOf(PdfListFieldItem)

Gets the index of the specified item.

public int IndexOf(PdfListFieldItem item)

Parameters

item PdfListFieldItem

A PdfListFieldItem object whose index is requested.

Returns

int

The index of the given item, -1 if the item does not exist.

Examples

//Create a new PDf document
PdfDocument document = new PdfDocument();           
//Creates a new page and adds it as the last page of the document
PdfPage page = document.Pages.Add();   
//Create list box
PdfListBoxField listBox = new PdfListBoxField(page, "list1");
//Add the field to listbox.
document.Form.Fields.Add(listBox);            
//Set the properties.
listBox.Bounds = new RectangleF(100, 350, 100, 50);            
// Creates list items
PdfListFieldItemCollection itemCollection = listBox.Items;
//Add the items to the list box            
PdfListFieldItem item = new PdfListFieldItem("English", "English");
itemCollection.Add(item);
itemCollection.Add(new PdfListFieldItem("French", "French"));
itemCollection.Add(new PdfListFieldItem("German", "German"));
// Gets the index of an item
int index = itemCollection.IndexOf(item);
document.Save("Form.pdf");
document.Close(true);
'Create a new PDf document
Dim document As PdfDocument = New PdfDocument()
'Create a page
Dim page As PdfPage = document.Pages.Add()
'Create list box
Dim listBox As PdfListBoxField = New PdfListBoxField(page, "list1")
'Add the field to listbox.
document.Form.Fields.Add(listBox)
'Set the properties.
listBox.Bounds = New RectangleF(100, 350, 100, 50)
' Creates list items
Dim itemCollection As PdfListFieldItemCollection = listBox.Items
'Add the items to the list box            
Dim item As PdfListFieldItem = New PdfListFieldItem("English", "English")
itemCollection.Add(item)
itemCollection.Add(New PdfListFieldItem("French", "French"))
itemCollection.Add(New PdfListFieldItem("German", "German"))
' Gets the index of an item
Dim index As Integer = itemCollection.IndexOf(item)
document.Save("Form.pdf")
document.Close(True)
See Also

Insert(int, PdfListFieldItem)

Inserts the list item field at the specified index.

public void Insert(int index, PdfListFieldItem item)

Parameters

index int

The index where to insert the new item.

item PdfListFieldItem

The PdfListFieldItem object to be added to collection.

Examples

//Create a new PDf document
PdfDocument document = new PdfDocument();           
//Creates a new page and adds it as the last page of the document
PdfPage page = document.Pages.Add();    
//Create list box
PdfListBoxField listBox = new PdfListBoxField(page, "list1");
//Add the field to listbox.
document.Form.Fields.Add(listBox);            
//Set the properties.
listBox.Bounds = new RectangleF(100, 350, 100, 50);
listBox.HighlightMode = PdfHighlightMode.Outline;            
// Creates list items
PdfListFieldItemCollection itemCollection = listBox.Items;
//Add the items to the list box
itemCollection.Add(new PdfListFieldItem("English", "English"));
itemCollection.Add(new PdfListFieldItem("French", "French"));
itemCollection.Add(new PdfListFieldItem("German", "German"));
PdfListFieldItem item = new PdfListFieldItem("Arabic", "Arabic");
// Inserting an item at second position
itemCollection.Insert(1, item);
document.Save("Form.pdf");
document.Close(true);
'Create a new PDf document
Dim document As PdfDocument = New PdfDocument()
'Create a page
Dim page As PdfPage = document.Pages.Add()
'Create list box
Dim listBox As PdfListBoxField = New PdfListBoxField(page, "list1")
'Add the field to listbox.
document.Form.Fields.Add(listBox)
'Set the properties.
listBox.Bounds = New RectangleF(100, 350, 100, 50)
listBox.HighlightMode = PdfHighlightMode.Outline
' Creates list items
Dim itemCollection As PdfListFieldItemCollection = listBox.Items
'Add the items to the list box
itemCollection.Add(New PdfListFieldItem("English", "English"))
itemCollection.Add(New PdfListFieldItem("French", "French"))
itemCollection.Add(New PdfListFieldItem("German", "German"))
Dim item As PdfListFieldItem = New PdfListFieldItem("Arabic", "Arabic")
' Inserting an item at second position
itemCollection.Insert(1, item)
document.Save("Form.pdf")
document.Close(True)
See Also

Remove(PdfListFieldItem)

Removes the specified PdfListFieldItem.

public void Remove(PdfListFieldItem item)

Parameters

item PdfListFieldItem

The PdfListFieldItem object which to be removed in the collection.

Examples

//Create a new PDf document
PdfDocument document = new PdfDocument();           
//Creates a new page and adds it as the last page of the document
PdfPage page = document.Pages.Add();   
//Create list box
PdfListBoxField listBox = new PdfListBoxField(page, "list1");
//Add the field to listbox.
document.Form.Fields.Add(listBox);            
//Set the properties.
listBox.Bounds = new RectangleF(100, 350, 100, 50);            
// Creates list items
PdfListFieldItemCollection itemCollection = listBox.Items;
//Add the items to the list box            
PdfListFieldItem item = new PdfListFieldItem("English", "English");
itemCollection.Add(item);
itemCollection.Add(new PdfListFieldItem("French", "French"));
itemCollection.Add(new PdfListFieldItem("German", "German"));
// Remove an item from collection
itemCollection.Remove(item);
document.Save("Form.pdf");
document.Close(true);
'Create a new PDf document
Dim document As PdfDocument = New PdfDocument()
'Create a page
Dim page As PdfPage = document.Pages.Add()
'Create list box
Dim listBox As PdfListBoxField = New PdfListBoxField(page, "list1")
'Add the field to listbox.
document.Form.Fields.Add(listBox)
'Set the properties.
listBox.Bounds = New RectangleF(100, 350, 100, 50)
' Creates list items
Dim itemCollection As PdfListFieldItemCollection = listBox.Items
'Add the items to the list box            
Dim item As PdfListFieldItem = New PdfListFieldItem("English", "English")
itemCollection.Add(item)
itemCollection.Add(New PdfListFieldItem("French", "French"))
itemCollection.Add(New PdfListFieldItem("German", "German"))
' Remove an item from collection
itemCollection.Remove(item)
document.Save("Form.pdf")
document.Close(True)
See Also

RemoveAt(int)

Removes the item at the specified position.

public void RemoveAt(int index)

Parameters

index int

The index where to remove the item.

Examples

//Create a new PDf document
PdfDocument document = new PdfDocument();           
//Creates a new page and adds it as the last page of the document
PdfPage page = document.Pages.Add();   
//Create list box
PdfListBoxField listBox = new PdfListBoxField(page, "list1");
//Add the field to listbox.
document.Form.Fields.Add(listBox);            
//Set the properties.
listBox.Bounds = new RectangleF(100, 350, 100, 50);            
// Creates list items
PdfListFieldItemCollection itemCollection = listBox.Items;
//Add the items to the list box            
PdfListFieldItem item = new PdfListFieldItem("English", "English");
itemCollection.Add(item);
itemCollection.Add(new PdfListFieldItem("French", "French"));
itemCollection.Add(new PdfListFieldItem("German", "German"));
// Remove an item from collection
itemCollection.RemoveAt(1);
document.Save("Form.pdf");
document.Close(true);
'Create a new PDf document
Dim document As PdfDocument = New PdfDocument()
'Create a page
Dim page As PdfPage = document.Pages.Add()
'Create list box
Dim listBox As PdfListBoxField = New PdfListBoxField(page, "list1")
'Add the field to listbox.
document.Form.Fields.Add(listBox)
'Set the properties.
listBox.Bounds = New RectangleF(100, 350, 100, 50)
' Creates list items
Dim itemCollection As PdfListFieldItemCollection = listBox.Items
'Add the items to the list box            
Dim item As PdfListFieldItem = New PdfListFieldItem("English", "English")
itemCollection.Add(item)
itemCollection.Add(New PdfListFieldItem("French", "French"))
itemCollection.Add(New PdfListFieldItem("German", "German"))
' Remove an item from collection
itemCollection.RemoveAt(1)
document.Save("Form.pdf")
document.Close(True)
See Also

See Also