Class PdfListFieldItemCollection
Represents list field item collection.
Implements
Inherited Members
Namespace: Syncfusion.Pdf.Interactive
Assembly: Syncfusion.Pdf.Base.dll
Syntax
public class PdfListFieldItemCollection : PdfCollection, IEnumerable, IPdfWrapper
Remarks
This PdfListFieldItemCollection class is used to get the collection of list field items in PDF forms. Please refer the UG docuemntation link https://help.syncfusion.com/file-formats/pdf/working-with-forms#adding-the-list-box-field for more details
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)
Constructors
PdfListFieldItemCollection()
Initializes a new instance of the PdfListFieldItemCollection class.
Declaration
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
Item[Int32]
Gets the PdfListFieldItem at the specified index.[Read-Only]
Declaration
public PdfListFieldItem this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index |
Property Value
Type | Description |
---|---|
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.
Declaration
public int Add(PdfListFieldItem item)
Parameters
Type | Name | Description |
---|---|---|
PdfListFieldItem | item | The PdfListFieldItem object which to be added in the collection. |
Returns
Type | Description |
---|---|
System.Int32 | 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.
Declaration
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.
Declaration
public bool Contains(PdfListFieldItem item)
Parameters
Type | Name | Description |
---|---|---|
PdfListFieldItem | item | Check whether PdfListFieldItem object is exists in the collection or not. |
Returns
Type | Description |
---|---|
System.Boolean |
|
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.
Declaration
public int IndexOf(PdfListFieldItem item)
Parameters
Type | Name | Description |
---|---|---|
PdfListFieldItem | item | A PdfListFieldItem object whose index is requested. |
Returns
Type | Description |
---|---|
System.Int32 | 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(Int32, PdfListFieldItem)
Inserts the list item field at the specified index.
Declaration
public void Insert(int index, PdfListFieldItem item)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The index where to insert the new item. |
PdfListFieldItem | item | 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.
Declaration
public void Remove(PdfListFieldItem item)
Parameters
Type | Name | Description |
---|---|---|
PdfListFieldItem | item | 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(Int32)
Removes the item at the specified position.
Declaration
public void RemoveAt(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | 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)