Table of Contents

Class PdfXfaComboBoxField

Namespace
Syncfusion.Pdf.Xfa
Assembly
Syncfusion.Pdf.Portable.dll

Represents the combo box field of the XFA form.

public class PdfXfaComboBoxField : PdfXfaStyledField
Inheritance
PdfXfaComboBoxField
Inherited Members

Examples

//Create a new XFA document 
PdfXfaDocument document = new PdfXfaDocument();
//Create a new XFA form
PdfXfaForm form = new PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595);
//Create a new XFA combo box field
PdfXfaComboBoxField field = new PdfXfaComboBoxField("combo1", new SizeF(100, 30));
//Add items.          
field.Items.Add("One");
field.Items.Add("Two");
field.Items.Add("Three");
field.Items.Add("Four");
field.Items.Add("Five");
//Add the field to the form
form.Fields.Add(field);            
document.XfaForm = form;
//Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic);
//Close the document
document.Close();
'Create a new XFA document 
Dim document As New PdfXfaDocument()
'Create a new XFA form
Dim form As New PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595)
'Create a new XFA combo box field
Dim field As New PdfXfaComboBoxField("combo1", New SizeF(100, 30))
'Add items.          
field.Items.Add("One")
field.Items.Add("Two")
field.Items.Add("Three")
field.Items.Add("Four")
field.Items.Add("Five")
'Add the field to the form
form.Fields.Add(field)
document.XfaForm = form
'Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic)
'Close the document
document.Close()

Constructors

PdfXfaComboBoxField(string, SizeF)

Initialize a new instance of the PdfXfaComboBoxField class.

public PdfXfaComboBoxField(string name, SizeF size)

Parameters

name string

The name of the field.

size SizeF

The size of the field.

Examples

//Create a new XFA document 
PdfXfaDocument document = new PdfXfaDocument();
//Create a new XFA form
PdfXfaForm form = new PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595);
//Create a new XFA combo box field
PdfXfaComboBoxField field = new PdfXfaComboBoxField("combo1", new SizeF(100, 30));
//Add items.          
field.Items.Add("One");
field.Items.Add("Two");
field.Items.Add("Three");
field.Items.Add("Four");
field.Items.Add("Five");
//Add the field to the form
form.Fields.Add(field);            
document.XfaForm = form;
//Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic);
//Close the document
document.Close();
'Create a new XFA document 
Dim document As New PdfXfaDocument()
'Create a new XFA form
Dim form As New PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595)
'Create a new XFA combo box field
Dim field As New PdfXfaComboBoxField("combo1", New SizeF(100, 30))
'Add items.          
field.Items.Add("One")
field.Items.Add("Two")
field.Items.Add("Three")
field.Items.Add("Four")
field.Items.Add("Five")
'Add the field to the form
form.Fields.Add(field)
document.XfaForm = form
'Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic)
'Close the document
document.Close()

PdfXfaComboBoxField(string, SizeF, List<string>)

Initialize a new instance of the PdfXfaComboBoxField class.

public PdfXfaComboBoxField(string name, SizeF size, List<string> items)

Parameters

name string

The name of the field.

size SizeF

Size of the field.

items List<string>

Field items.

Examples

//Create a new XFA document 
PdfXfaDocument document = new PdfXfaDocument();
//Create a new XFA form
PdfXfaForm form = new PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595);
List<string> items = new List<string>() { "One", "Two", "Three", "Four", "Five" };
//Create a new XFA combo box field
PdfXfaComboBoxField field = new PdfXfaComboBoxField("combo1", new SizeF(100, 30), items);        
//Add the field to the form
form.Fields.Add(field);            
document.XfaForm = form;
//Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic);
//Close the document
document.Close();
'Create a new XFA document 
Dim document As New PdfXfaDocument()
'Create a new XFA form
Dim form As New PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595)
Dim items As New List(Of String)()
items.Add("One")
items.Add("Two")
items.Add("Three")
items.Add("Four")
items.Add("Five")
'Create a new XFA combo box field
Dim field As New PdfXfaComboBoxField("combo1", New SizeF(100, 30), items)       
'Add the field to the form
form.Fields.Add(field)
document.XfaForm = form
'Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic)
'Close the document
document.Close()

PdfXfaComboBoxField(string, float, float)

Initialize a new instance of the PdfXfaComboBoxField class.

public PdfXfaComboBoxField(string name, float width, float height)

Parameters

name string

The name of the field.

width float

Width of the field.

height float

Height of the field.

Examples

//Create a new XFA document 
PdfXfaDocument document = new PdfXfaDocument();
//Create a new XFA form
PdfXfaForm form = new PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595);
//Create a new XFA combo box field
PdfXfaComboBoxField field = new PdfXfaComboBoxField("combo1", 100, 30);
//Add items.          
field.Items.Add("One");
field.Items.Add("Two");
field.Items.Add("Three");
field.Items.Add("Four");
field.Items.Add("Five");
//Add the field to the form
form.Fields.Add(field);            
document.XfaForm = form;
//Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic);
//Close the document
document.Close();
'Create a new XFA document 
Dim document As New PdfXfaDocument()
'Create a new XFA form
Dim form As New PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595)
'Create a new XFA combo box field
Dim field As New PdfXfaComboBoxField("combo1", 100, 30)
'Add items.          
field.Items.Add("One")
field.Items.Add("Two")
field.Items.Add("Three")
field.Items.Add("Four")
field.Items.Add("Five")
'Add the field to the form
form.Fields.Add(field)
document.XfaForm = form
'Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic)
'Close the document
document.Close()

PdfXfaComboBoxField(string, float, float, List<string>)

Initialize a new instance of the PdfXfaComboBoxField class.

public PdfXfaComboBoxField(string name, float width, float height, List<string> items)

Parameters

name string

The name of the field.

width float

Width of the field.

height float

Height of the field.

items List<string>

Field items.

Examples

//Create a new XFA document 
PdfXfaDocument document = new PdfXfaDocument();
//Create a new XFA form
PdfXfaForm form = new PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595);
List<string> items = new List<string>() { "One", "Two", "Three", "Four", "Five" };
//Create a new XFA combo box field
PdfXfaComboBoxField field = new PdfXfaComboBoxField("combo1", 100, 30, items);        
//Add the field to the form
form.Fields.Add(field);            
document.XfaForm = form;
//Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic);
//Close the document
document.Close();
'Create a new XFA document 
Dim document As New PdfXfaDocument()
'Create a new XFA form
Dim form As New PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595)
Dim items As New List(Of String)()
items.Add("One")
items.Add("Two")
items.Add("Three")
items.Add("Four")
items.Add("Five")
'Create a new XFA combo box field
Dim field As New PdfXfaComboBoxField("combo1", 100, 30, items)        
'Add the field to the form
form.Fields.Add(field)
document.XfaForm = form
'Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic)
'Close the document
document.Close()

Properties

AllowTextEntry

Gets or sets the text entry

public bool AllowTextEntry { get; set; }

Property Value

bool

Examples

//Create a new XFA document 
PdfXfaDocument document = new PdfXfaDocument();
//Create a new XFA form
PdfXfaForm form = new PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595);
List<string> items = new List<string>() { "One", "Two", "Three", "Four", "Five" };
//Create a new XFA combo box field
PdfXfaComboBoxField field = new PdfXfaComboBoxField("combo1", new SizeF(100, 30));
//Set items.
field.Items = items;
//Set text entry.
field.AllowTextEntry = true;
//Add the field to the form
form.Fields.Add(field);
document.XfaForm = form;
//Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic);
//Close the document
document.Close();
'Create a new XFA document 
Dim document As New PdfXfaDocument()
'Create a new XFA form
Dim form As New PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595)
Dim items As New List(Of String)()
items.Add("One")
items.Add("Two")
items.Add("Three")
items.Add("Four")
items.Add("Five")
'Create a new XFA combo box field
Dim field As New PdfXfaComboBoxField("combo1", New SizeF(100, 30))
'Set items.
field.Items = items
'Set text entry.
field.AllowTextEntry = True
'Add the field to the form
form.Fields.Add(field)
document.XfaForm = form
'Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic)
'Close the document
document.Close()

Caption

Gets or sets the caption of the field

public PdfXfaCaption Caption { get; set; }

Property Value

PdfXfaCaption

Examples

//Create a new XFA document 
PdfXfaDocument document = new PdfXfaDocument();
//Create a new XFA form
PdfXfaForm form = new PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595);
List<string> items = new List<string>() { "One", "Two", "Three", "Four", "Five" };
//Create a new XFA combo box field
PdfXfaComboBoxField field = new PdfXfaComboBoxField("combo1", new SizeF(100, 30));
//Set paddings.
field.Padding.All = 2;
//Set data source.
field.DataSource = items;
//Set caption.
field.Caption.Text = "Combo Box";
//Add the field to the form
form.Fields.Add(field);
document.XfaForm = form;
//Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic);
//Close the document
document.Close();
'Create a new XFA document 
Dim document As New PdfXfaDocument()
'Create a new XFA form
Dim form As New PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595)
Dim items As New List(Of String)()
items.Add("One")
items.Add("Two")
items.Add("Three")
items.Add("Four")
items.Add("Five")
'Create a new XFA combo box field
Dim field As New PdfXfaComboBoxField("combo1", New SizeF(100, 30))
'Set paddings.
field.Padding.All = 2
'Set data source.
field.DataSource = items
'Set caption.
field.Caption.Text = "Combo Box"
'Add the field to the form
form.Fields.Add(field)
document.XfaForm = form
'Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic)
'Close the document
document.Close()

DataSource

Gets or set the combo box items.

public object DataSource { get; set; }

Property Value

object

Examples

//Create a new XFA document 
PdfXfaDocument document = new PdfXfaDocument();
//Create a new XFA form
PdfXfaForm form = new PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595);
List<string> items = new List<string>() { "One", "Two", "Three", "Four", "Five" };
//Create a new XFA combo box field
PdfXfaComboBoxField field = new PdfXfaComboBoxField("combo1", new SizeF(100, 30));
//Set paddings.
field.Padding.All = 2;
//Set data source.
field.DataSource = items;
//Set caption.
field.Caption.Text = "Combo Box";
//Add the field to the form
form.Fields.Add(field);
document.XfaForm = form;
//Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic);
//Close the document
document.Close();
'Create a new XFA document 
Dim document As New PdfXfaDocument()
'Create a new XFA form
Dim form As New PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595)
Dim items As New List(Of String)()
items.Add("One")
items.Add("Two")
items.Add("Three")
items.Add("Four")
items.Add("Five")
'Create a new XFA combo box field
Dim field As New PdfXfaComboBoxField("combo1", New SizeF(100, 30))
'Set paddings.
field.Padding.All = 2
'Set data source.
field.DataSource = items
'Set caption.
field.Caption.Text = "Combo Box"
'Add the field to the form
form.Fields.Add(field)
document.XfaForm = form
'Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic)
'Close the document
document.Close()

Remarks

It only supports the list of string or array of string values.

Items

Gets or sets the field items

public List<string> Items { get; set; }

Property Value

List<string>

Examples

//Create a new XFA document 
PdfXfaDocument document = new PdfXfaDocument();
//Create a new XFA form
PdfXfaForm form = new PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595);
List<string> items = new List<string>() { "One", "Two", "Three", "Four", "Five" };
//Create a new XFA combo box field
PdfXfaComboBoxField field = new PdfXfaComboBoxField("combo1", new SizeF(100, 30));       
//Set caption.
field.Caption.Text = "Combo Box";
//Set items.
field.Items = items;
//Add the field to the form
form.Fields.Add(field);
document.XfaForm = form;
//Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic);
//Close the document
document.Close();
'Create a new XFA document 
Dim document As New PdfXfaDocument()
'Create a new XFA form
Dim form As New PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595)
Dim items As New List(Of String)()
items.Add("One")
items.Add("Two")
items.Add("Three")
items.Add("Four")
items.Add("Five")
'Create a new XFA combo box field
Dim field As New PdfXfaComboBoxField("combo1", New SizeF(100, 30))        
'Set caption.
field.Caption.Text = "Combo Box"
'Set items.
field.Items = items        
'Add the field to the form
form.Fields.Add(field)
document.XfaForm = form
'Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic)
'Close the document
document.Close()

Padding

Gets or sets the padding

public PdfPaddings Padding { get; set; }

Property Value

PdfPaddings

Examples

//Create a new XFA document 
PdfXfaDocument document = new PdfXfaDocument();
//Create a new XFA form
PdfXfaForm form = new PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595);
List<string> items = new List<string>() { "One", "Two", "Three", "Four", "Five" };
//Create a new XFA combo box field
PdfXfaComboBoxField field = new PdfXfaComboBoxField("combo1", new SizeF(100, 30));
//Set paddings.
field.Padding.All = 2;
//Set data source.
field.DataSource = items;
//Set caption.
field.Caption.Text = "Combo Box";      
//Add the field to the form
form.Fields.Add(field);
document.XfaForm = form;
//Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic);
//Close the document
document.Close();
'Create a new XFA document 
Dim document As New PdfXfaDocument()
'Create a new XFA form
Dim form As New PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595)
Dim items As New List(Of String)()
items.Add("One")
items.Add("Two")
items.Add("Three")
items.Add("Four")
items.Add("Five")
'Create a new XFA combo box field
Dim field As New PdfXfaComboBoxField("combo1", New SizeF(100, 30))
'Set paddings.
field.Padding.All = 2
'Set data source.
field.DataSource = items
'Set caption.
field.Caption.Text = "Combo Box"     
'Add the field to the form
form.Fields.Add(field)
document.XfaForm = form
'Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic)
'Close the document
document.Close()

SelectedIndex

Gets or sets the selected index

public int SelectedIndex { get; set; }

Property Value

int

Examples

//Create a new XFA document 
PdfXfaDocument document = new PdfXfaDocument();
//Create a new XFA form
PdfXfaForm form = new PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595);
List<string> items = new List<string>() { "One", "Two", "Three", "Four", "Five" };
//Create a new XFA combo box field
PdfXfaComboBoxField field = new PdfXfaComboBoxField("combo1", new SizeF(100, 30));
//Set items.
field.Items = items;
//Set selected index.
field.SelectedIndex = 1;
//Add the field to the form
form.Fields.Add(field);
document.XfaForm = form;
//Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic);
//Close the document
document.Close();
'Create a new XFA document 
Dim document As New PdfXfaDocument()
'Create a new XFA form
Dim form As New PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595)
Dim items As New List(Of String)()
items.Add("One")
items.Add("Two")
items.Add("Three")
items.Add("Four")
items.Add("Five")
'Create a new XFA combo box field
Dim field As New PdfXfaComboBoxField("combo1", New SizeF(100, 30))
'Set items.
field.Items = items
'Set selected index.
field.SelectedIndex = 1
'Add the field to the form
form.Fields.Add(field)
document.XfaForm = form
'Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic)
'Close the document
document.Close()

SelectedValue

Gets or sets the selected value

public string SelectedValue { get; set; }

Property Value

string

Examples

//Create a new XFA document 
PdfXfaDocument document = new PdfXfaDocument();
//Create a new XFA form
PdfXfaForm form = new PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595);
List<string> items = new List<string>() { "One", "Two", "Three", "Four", "Five" };
//Create a new XFA combo box field
PdfXfaComboBoxField field = new PdfXfaComboBoxField("combo1", new SizeF(100, 30));
//Set items.
field.Items = items;
//Set selected value
field.SelectedValue = "Three";
//Add the field to the form
form.Fields.Add(field);
document.XfaForm = form;
//Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic);
//Close the document
document.Close();
'Create a new XFA document 
Dim document As New PdfXfaDocument()
'Create a new XFA form
Dim form As New PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595)
Dim items As New List(Of String)()
items.Add("One")
items.Add("Two")
items.Add("Three")
items.Add("Four")
items.Add("Five")
'Create a new XFA combo box field
Dim field As New PdfXfaComboBoxField("combo1", New SizeF(100, 30))
'Set items.
field.Items = items
'Set selected value
field.SelectedValue = "Three"
'Add the field to the form
form.Fields.Add(field)
document.XfaForm = form
'Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic)
'Close the document
document.Close()

Methods

Clone()

Creates a new object that is a copy of the current instance.

public object Clone()

Returns

object

The copy of the new object for this instance.

Examples

//Create a new XFA document 
PdfXfaDocument document = new PdfXfaDocument();
//Create a new XFA form
PdfXfaForm form = new PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595);     
//Create a new XFA combo box field
PdfXfaComboBoxField field = new PdfXfaComboBoxField("combo1", new SizeF(100, 30));
//Add items.          
field.Items.Add("One");
field.Items.Add("Two");
field.Items.Add("Three");
field.Items.Add("Four");
field.Items.Add("Five");
//Add the field to the form
form.Fields.Add(field); 
//Clone the combo box field.
form.Fields.Add(field.Clone() as PdfXfaComboBoxField);  
document.XfaForm = form;
//Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic);
//Close the document
document.Close();
'Create a new XFA document 
Dim document As New PdfXfaDocument()
'Create a new XFA form
Dim form As New PdfXfaForm(PdfXfaFlowDirection.Horizontal, 595)      
'Create a new XFA combo box field
Dim field As New PdfXfaComboBoxField("combo1", New SizeF(100, 30))
'Add items.          
field.Items.Add("One")
field.Items.Add("Two")
field.Items.Add("Three")
field.Items.Add("Four")
field.Items.Add("Five")
'Add the field to the form
form.Fields.Add(field)
'Clone the combo box field.
xfaForm.Fields.Add( TryCast(field.Clone(), PdfXfaComboBoxField))  
document.XfaForm = form
'Save the document           
document.Save("output.pdf", PdfXfaType.Dynamic)
'Close the document
document.Close()