Class PdfListFieldItem
Represents an item of the list fields.
Inheritance
System.Object
PdfListFieldItem
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Syncfusion.Pdf.Interactive
Assembly: Syncfusion.Pdf.Base.dll
Syntax
public class PdfListFieldItem : IPdfWrapper
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 list box.
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;
//Gets the selected item
PdfListFieldItem selectedItem = listBox.SelectedItem;
MessageBox.Show("Selected Item text : " + selectedItem.Text);
MessageBox.Show("Selected Item value : " + selectedItem.Value);
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 list box.
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
'Gets the selected item
Dim selectedItem As PdfListFieldItem = listBox.SelectedItem
MessageBox.Show("Selected Item text : " + selectedItem.Text)
MessageBox.Show("Selected Item value : " + selectedItem.Value)
document.Save("Form.pdf")
document.Close(True)
Constructors
PdfListFieldItem()
Initializes a new instance of the PdfListFieldItem class.
Declaration
public PdfListFieldItem()
PdfListFieldItem(String, String)
Initializes a new instance of the PdfListFieldItem class with the specific text and value.
Declaration
public PdfListFieldItem(string text, string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The item text, it is displayed in the list. |
System.String | value | The item value, it is exported when form content is exported. |
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"));
listBox.SelectedIndex = 0;
//Gets the selected item
PdfListFieldItem selectedItem = listBox.SelectedItem;
MessageBox.Show("Selected Item text : " + selectedItem.Text);
MessageBox.Show("Selected Item value : " + selectedItem.Value);
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"))
listBox.SelectedIndex = 0
'Gets the selected item
Dim selectedItem As PdfListFieldItem = listBox.SelectedItem
MessageBox.Show("Selected Item text : " + selectedItem.Text)
MessageBox.Show("Selected Item value : " + selectedItem.Value)
document.Save("Form.pdf")
document.Close(True)
See Also
Properties
Text
Gets or sets the text.
Declaration
public string Text { get; set; }
Property Value
Type | Description |
---|---|
System.String | The text of the list item field. |
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();
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;
//Gets the selected item
PdfListFieldItem selectedItem = listBox.SelectedItem;
MessageBox.Show("Selected Item text : " + selectedItem.Text);
MessageBox.Show("Selected Item value : " + selectedItem.Value);
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)
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
'Gets the selected item
Dim selectedItem As PdfListFieldItem = listBox.SelectedItem
MessageBox.Show("Selected Item text : " + selectedItem.Text)
MessageBox.Show("Selected Item value : " + selectedItem.Value)
document.Save("Form.pdf")
document.Close(True)
See Also
Value
Gets or sets the value.
Declaration
public string Value { get; set; }
Property Value
Type | Description |
---|---|
System.String | The value of the list item field. |
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();
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;
//Gets the selected item
PdfListFieldItem selectedItem = listBox.SelectedItem;
MessageBox.Show("Selected Item text : " + selectedItem.Text);
MessageBox.Show("Selected Item value : " + selectedItem.Value);
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)
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
'Gets the selected item
Dim selectedItem As PdfListFieldItem = listBox.SelectedItem
MessageBox.Show("Selected Item text : " + selectedItem.Text)
MessageBox.Show("Selected Item value : " + selectedItem.Value)
document.Save("Form.pdf")
document.Close(True)