Class PdfXfaListBoxField
Represents the list box field of the XFA form.
Inherited Members
Namespace: Syncfusion.Pdf.Xfa
Assembly: Syncfusion.Pdf.Portable.dll
Syntax
public class PdfXfaListBoxField : PdfXfaStyledField
Examples
//Create a new PDF XFA document.
PdfXfaDocument document = new PdfXfaDocument();
//Add a new XFA page.
PdfXfaPage xfaPage = document.Pages.Add();
//Create a new PDF XFA form
PdfXfaForm mainForm = new PdfXfaForm("subform1", xfaPage, xfaPage.GetClientSize().Width);
//Create a list box field and add the properties.
PdfXfaListBoxField listBoxField = new PdfXfaListBoxField("listBoxField", new SizeF(150, 50));
//Set the caption text.
listBoxField.Caption.Text = "Known Languages";
listBoxField.Caption.Position = PdfXfaPosition.Top;
listBoxField.Caption.HorizontalAlignment = PdfXfaHorizontalAlignment.Center;
//Add the list box items
listBoxField.Items.Add("English");
listBoxField.Items.Add("French");
listBoxField.Items.Add("German");
//Add the field to the XFA form.
mainForm.Fields.Add(listBoxField);
//Add the XFA form to the document.
document.XfaForm = mainForm;
//Save the document.
document.Save("output.pdf", PdfXfaType.Dynamic);
//close the document
document.Close();
'Create a new PDF XFA document.
Dim document As New PdfXfaDocument()
'Add a new XFA page.
Dim xfaPage As PdfXfaPage = document.Pages.Add()
'Create a new PDF XFA form
Dim mainForm As New PdfXfaForm("subform1", xfaPage, xfaPage.GetClientSize().Width)
'Create a list box field and add the properties.
Dim listBoxField As New PdfXfaListBoxField("listBoxField", New SizeF(150, 50))
'Set the caption text.
listBoxField.Caption.Text = "Known Languages"
listBoxField.Caption.Position = PdfXfaPosition.Top
listBoxField.Caption.HorizontalAlignment = PdfXfaHorizontalAlignment.Center
'Add the list box items
listBoxField.Items.Add("English")
listBoxField.Items.Add("French")
listBoxField.Items.Add("German")
'Add the field to the XFA form.
mainForm.Fields.Add(listBoxField)
'Add the XFA form to the document.
document.XfaForm = mainForm
'Save the document.
document.Save("output.pdf",PdfXfaType.Dynamic)
'close the document
document.Close()
Constructors
PdfXfaListBoxField(String, SizeF)
Initialize a new instance of the PdfXfaListBoxField class.
Declaration
public PdfXfaListBoxField(string name, SizeF size)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Field name. |
SizeF | size | Field size. |
Examples
//Create a new PDF XFA document.
PdfXfaDocument document = new PdfXfaDocument();
//Add a new XFA page.
PdfXfaPage xfaPage = document.Pages.Add();
//Create a new PDF XFA form
PdfXfaForm mainForm = new PdfXfaForm("subform1", xfaPage, xfaPage.GetClientSize().Width);
//Create a list box field and add the properties.
PdfXfaListBoxField listBoxField = new PdfXfaListBoxField("listBoxField", new SizeF(150, 50));
//Set the caption text.
listBoxField.Caption.Text = "Known Languages";
listBoxField.Caption.Position = PdfXfaPosition.Top;
listBoxField.Caption.HorizontalAlignment = PdfXfaHorizontalAlignment.Center;
//Add the list box items
listBoxField.Items.Add("English");
listBoxField.Items.Add("French");
listBoxField.Items.Add("German");
//Add the field to the XFA form.
mainForm.Fields.Add(listBoxField);
//Add the XFA form to the document.
document.XfaForm = mainForm;
//Save the document.
document.Save("output.pdf", PdfXfaType.Dynamic);
//close the document
document.Close();
'Create a new PDF XFA document.
Dim document As New PdfXfaDocument()
'Add a new XFA page.
Dim xfaPage As PdfXfaPage = document.Pages.Add()
'Create a new PDF XFA form
Dim mainForm As New PdfXfaForm("subform1", xfaPage, xfaPage.GetClientSize().Width)
'Create a list box field and add the properties.
Dim listBoxField As New PdfXfaListBoxField("listBoxField", New SizeF(150, 50))
'Set the caption text.
listBoxField.Caption.Text = "Known Languages"
listBoxField.Caption.Position = PdfXfaPosition.Top
listBoxField.Caption.HorizontalAlignment = PdfXfaHorizontalAlignment.Center
'Add the list box items
listBoxField.Items.Add("English")
listBoxField.Items.Add("French")
listBoxField.Items.Add("German")
'Add the field to the XFA form.
mainForm.Fields.Add(listBoxField)
'Add the XFA form to the document.
document.XfaForm = mainForm
'Save the document.
document.Save("output.pdf",PdfXfaType.Dynamic)
'close the document
document.Close()
PdfXfaListBoxField(String, SizeF, List<String>)
Initialize a new instance of the PdfXfaListBoxField class.
Declaration
public PdfXfaListBoxField(string name, SizeF size, List<string> items)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Field name. |
SizeF | size | Field size. |
System.Collections.Generic.List<System.String> | items | Field items. |
Examples
//Create a new PDF XFA document.
PdfXfaDocument document = new PdfXfaDocument();
//Add a new XFA page.
PdfXfaPage xfaPage = document.Pages.Add();
//Create a new PDF XFA form
PdfXfaForm mainForm = new PdfXfaForm("subform1", xfaPage, xfaPage.GetClientSize().Width);
List<string> items = new List<string>() { "English", "French", "German" };
//Create a list box field and add the properties.
PdfXfaListBoxField listBoxField = new PdfXfaListBoxField("listBoxField", new SizeF(150, 50), items);
//Set the caption text.
listBoxField.Caption.Text = "Known Languages";
listBoxField.Caption.Position = PdfXfaPosition.Top;
listBoxField.Caption.HorizontalAlignment = PdfXfaHorizontalAlignment.Center;
//Add the field to the XFA form.
mainForm.Fields.Add(listBoxField);
//Add the XFA form to the document.
document.XfaForm = mainForm;
//Save the document.
document.Save("output.pdf", PdfXfaType.Dynamic);
//close the document
document.Close();
'Create a new PDF XFA document.
Dim document As New PdfXfaDocument()
'Add a new XFA page.
Dim xfaPage As PdfXfaPage = document.Pages.Add()
'Create a new PDF XFA form
Dim mainForm As New PdfXfaForm("subform1", xfaPage, xfaPage.GetClientSize().Width)
Dim items As New List(Of String)()
items.Add("English")
items.Add("French")
items.Add("German")
'Create a list box field and add the properties.
Dim listBoxField As New PdfXfaListBoxField("listBoxField", New SizeF(150, 50), items)
'Set the caption text.
listBoxField.Caption.Text = "Known Languages"
listBoxField.Caption.Position = PdfXfaPosition.Top
listBoxField.Caption.HorizontalAlignment = PdfXfaHorizontalAlignment.Center
'Add the field to the XFA form.
mainForm.Fields.Add(listBoxField)
'Add the XFA form to the document.
document.XfaForm = mainForm
'Save the document.
document.Save("output.pdf",PdfXfaType.Dynamic)
'close the document
document.Close()
PdfXfaListBoxField(String, Single, Single)
Initialize a new instance of the PdfXfaListBoxField class.
Declaration
public PdfXfaListBoxField(string name, float width, float height)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Field name. |
System.Single | width | Field width. |
System.Single | height | Field height. |
Examples
//Create a new PDF XFA document.
PdfXfaDocument document = new PdfXfaDocument();
//Add a new XFA page.
PdfXfaPage xfaPage = document.Pages.Add();
//Create a new PDF XFA form
PdfXfaForm mainForm = new PdfXfaForm("subform1", xfaPage, xfaPage.GetClientSize().Width);
//Create a list box field and add the properties.
PdfXfaListBoxField listBoxField = new PdfXfaListBoxField("listBoxField", 150, 50);
//Set the caption text.
listBoxField.Caption.Text = "Known Languages";
listBoxField.Caption.Position = PdfXfaPosition.Top;
listBoxField.Caption.HorizontalAlignment = PdfXfaHorizontalAlignment.Center;
//Add the list box items
listBoxField.Items.Add("English");
listBoxField.Items.Add("French");
listBoxField.Items.Add("German");
//Add the field to the XFA form.
mainForm.Fields.Add(listBoxField);
//Add the XFA form to the document.
document.XfaForm = mainForm;
//Save the document.
document.Save("output.pdf", PdfXfaType.Dynamic);
//close the document
document.Close();
'Create a new PDF XFA document.
Dim document As New PdfXfaDocument()
'Add a new XFA page.
Dim xfaPage As PdfXfaPage = document.Pages.Add()
'Create a new PDF XFA form
Dim mainForm As New PdfXfaForm("subform1", xfaPage, xfaPage.GetClientSize().Width)
'Create a list box field and add the properties.
Dim listBoxField As New PdfXfaListBoxField("listBoxField", 150, 50)
'Set the caption text.
listBoxField.Caption.Text = "Known Languages"
listBoxField.Caption.Position = PdfXfaPosition.Top
listBoxField.Caption.HorizontalAlignment = PdfXfaHorizontalAlignment.Center
'Add the list box items
listBoxField.Items.Add("English")
listBoxField.Items.Add("French")
listBoxField.Items.Add("German")
'Add the field to the XFA form.
mainForm.Fields.Add(listBoxField)
'Add the XFA form to the document.
document.XfaForm = mainForm
'Save the document.
document.Save("output.pdf",PdfXfaType.Dynamic)
'close the document
document.Close()
PdfXfaListBoxField(String, Single, Single, List<String>)
Initialize a new instance of the PdfXfaListBoxField class.
Declaration
public PdfXfaListBoxField(string name, float width, float height, List<string> items)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Field name. |
System.Single | width | Field width. |
System.Single | height | Field height. |
System.Collections.Generic.List<System.String> | items | Field items. |
Examples
//Create a new PDF XFA document.
PdfXfaDocument document = new PdfXfaDocument();
//Add a new XFA page.
PdfXfaPage xfaPage = document.Pages.Add();
//Create a new PDF XFA form
PdfXfaForm mainForm = new PdfXfaForm("subform1", xfaPage, xfaPage.GetClientSize().Width);
List<string> items = new List<string>() { "English", "French", "German" };
//Create a list box field and add the properties.
PdfXfaListBoxField listBoxField = new PdfXfaListBoxField("listBoxField", 150, 50, items);
//Set the caption text.
listBoxField.Caption.Text = "Known Languages";
listBoxField.Caption.Position = PdfXfaPosition.Top;
listBoxField.Caption.HorizontalAlignment = PdfXfaHorizontalAlignment.Center;
//Add the field to the XFA form.
mainForm.Fields.Add(listBoxField);
//Add the XFA form to the document.
document.XfaForm = mainForm;
//Save the document.
document.Save("output.pdf", PdfXfaType.Dynamic);
//close the document
document.Close();
'Create a new PDF XFA document.
Dim document As New PdfXfaDocument()
'Add a new XFA page.
Dim xfaPage As PdfXfaPage = document.Pages.Add()
'Create a new PDF XFA form
Dim mainForm As New PdfXfaForm("subform1", xfaPage, xfaPage.GetClientSize().Width)
Dim items As New List(Of String)()
items.Add("English")
items.Add("French")
items.Add("German")
'Create a list box field and add the properties.
Dim listBoxField As New PdfXfaListBoxField("listBoxField", 150, 50, items)
'Set the caption text.
listBoxField.Caption.Text = "Known Languages"
listBoxField.Caption.Position = PdfXfaPosition.Top
listBoxField.Caption.HorizontalAlignment = PdfXfaHorizontalAlignment.Center
'Add the field to the XFA form.
mainForm.Fields.Add(listBoxField)
'Add the XFA form to the document.
document.XfaForm = mainForm
'Save the document.
document.Save("output.pdf",PdfXfaType.Dynamic)
'close the document
document.Close()
Properties
Caption
Gets or sets the caption of the field
Declaration
public PdfXfaCaption Caption { get; set; }
Property Value
Type |
---|
PdfXfaCaption |
Examples
//Create a new PDF XFA document.
PdfXfaDocument document = new PdfXfaDocument();
//Add a new XFA page.
PdfXfaPage xfaPage = document.Pages.Add();
//Create a new PDF XFA form
PdfXfaForm mainForm = new PdfXfaForm("subform1", xfaPage, xfaPage.GetClientSize().Width);
//Create a list box field and add the properties.
PdfXfaListBoxField listBoxField = new PdfXfaListBoxField("listBoxField", new SizeF(150, 50));
//Set the caption text.
listBoxField.Caption.Text = "Known Languages";
listBoxField.Caption.Position = PdfXfaPosition.Top;
listBoxField.Caption.HorizontalAlignment = PdfXfaHorizontalAlignment.Center;
//Add the list box items
listBoxField.Items.Add("English");
listBoxField.Items.Add("French");
listBoxField.Items.Add("German");
//Add the field to the XFA form.
mainForm.Fields.Add(listBoxField);
//Add the XFA form to the document.
document.XfaForm = mainForm;
//Save the document.
document.Save("output.pdf", PdfXfaType.Dynamic);
//close the document
document.Close();
'Create a new PDF XFA document.
Dim document As New PdfXfaDocument()
'Add a new XFA page.
Dim xfaPage As PdfXfaPage = document.Pages.Add()
'Create a new PDF XFA form
Dim mainForm As New PdfXfaForm("subform1", xfaPage, xfaPage.GetClientSize().Width)
'Create a list box field and add the properties.
Dim listBoxField As New PdfXfaListBoxField("listBoxField", New SizeF(150, 50))
'Set the caption text.
listBoxField.Caption.Text = "Known Languages"
listBoxField.Caption.Position = PdfXfaPosition.Top
listBoxField.Caption.HorizontalAlignment = PdfXfaHorizontalAlignment.Center
'Add the list box items
listBoxField.Items.Add("English")
listBoxField.Items.Add("French")
listBoxField.Items.Add("German")
'Add the field to the XFA form.
mainForm.Fields.Add(listBoxField)
'Add the XFA form to the document.
document.XfaForm = mainForm
'Save the document.
document.Save("output.pdf",PdfXfaType.Dynamic)
'close the document
document.Close()
DataSource
Gets or set the list box items.
Declaration
public object DataSource { get; set; }
Property Value
Type |
---|
System.Object |
Remarks
It only supports the list of string or array of string values.
Examples
//Create a new PDF XFA document.
PdfXfaDocument document = new PdfXfaDocument();
//Add a new XFA page.
PdfXfaPage xfaPage = document.Pages.Add();
//Create a new PDF XFA form
PdfXfaForm mainForm = new PdfXfaForm("subform1", xfaPage, xfaPage.GetClientSize().Width);
List<string> items = new List<string>() { "English", "French", "German" };
//Create a list box field and add the properties.
PdfXfaListBoxField listBoxField = new PdfXfaListBoxField("listBoxField", new SizeF(150, 50));
//Set the caption text.
listBoxField.Caption.Text = "Known Languages";
listBoxField.Caption.Position = PdfXfaPosition.Top;
listBoxField.Caption.HorizontalAlignment = PdfXfaHorizontalAlignment.Center;
//Set data source.
listBoxField.DataSource = items;
//Add the field to the XFA form.
mainForm.Fields.Add(listBoxField);
//Add the XFA form to the document.
document.XfaForm = mainForm;
//Save the document.
document.Save("output.pdf", PdfXfaType.Dynamic);
//close the document
document.Close();
'Create a new PDF XFA document.
Dim document As New PdfXfaDocument()
'Add a new XFA page.
Dim xfaPage As PdfXfaPage = document.Pages.Add()
'Create a new PDF XFA form
Dim mainForm As New PdfXfaForm("subform1", xfaPage, xfaPage.GetClientSize().Width)
Dim items As New List(Of String)()
items.Add("English")
items.Add("French")
items.Add("German")
'Create a list box field and add the properties.
Dim listBoxField As New PdfXfaListBoxField("listBoxField", New SizeF(150, 50))
'Set the caption text.
listBoxField.Caption.Text = "Known Languages"
listBoxField.Caption.Position = PdfXfaPosition.Top
listBoxField.Caption.HorizontalAlignment = PdfXfaHorizontalAlignment.Center
'Set data source.
listBoxField.DataSource = items
'Add the field to the XFA form.
mainForm.Fields.Add(listBoxField)
'Add the XFA form to the document.
document.XfaForm = mainForm
'Save the document.
document.Save("output.pdf",PdfXfaType.Dynamic)
'close the document
document.Close()
Items
Gets or sets the list box items
Declaration
public List<string> Items { get; set; }
Property Value
Type |
---|
System.Collections.Generic.List<System.String> |
Examples
//Create a new PDF XFA document.
PdfXfaDocument document = new PdfXfaDocument();
//Add a new XFA page.
PdfXfaPage xfaPage = document.Pages.Add();
//Create a new PDF XFA form
PdfXfaForm mainForm = new PdfXfaForm("subform1", xfaPage, xfaPage.GetClientSize().Width);
//Create a list box field and add the properties.
PdfXfaListBoxField listBoxField = new PdfXfaListBoxField("listBoxField", new SizeF(150, 50));
//Set the caption text.
listBoxField.Caption.Text = "Known Languages";
listBoxField.Caption.Position = PdfXfaPosition.Top;
listBoxField.Caption.HorizontalAlignment = PdfXfaHorizontalAlignment.Center;
//Add the list box items
listBoxField.Items.Add("English");
listBoxField.Items.Add("French");
listBoxField.Items.Add("German");
//Add the field to the XFA form.
mainForm.Fields.Add(listBoxField);
//Add the XFA form to the document.
document.XfaForm = mainForm;
//Save the document.
document.Save("output.pdf", PdfXfaType.Dynamic);
//close the document
document.Close();
'Create a new PDF XFA document.
Dim document As New PdfXfaDocument()
'Add a new XFA page.
Dim xfaPage As PdfXfaPage = document.Pages.Add()
'Create a new PDF XFA form
Dim mainForm As New PdfXfaForm("subform1", xfaPage, xfaPage.GetClientSize().Width)
'Create a list box field and add the properties.
Dim listBoxField As New PdfXfaListBoxField("listBoxField", New SizeF(150, 50))
'Set the caption text.
listBoxField.Caption.Text = "Known Languages"
listBoxField.Caption.Position = PdfXfaPosition.Top
listBoxField.Caption.HorizontalAlignment = PdfXfaHorizontalAlignment.Center
'Add the list box items
listBoxField.Items.Add("English")
listBoxField.Items.Add("French")
listBoxField.Items.Add("German")
'Add the field to the XFA form.
mainForm.Fields.Add(listBoxField)
'Add the XFA form to the document.
document.XfaForm = mainForm
'Save the document.
document.Save("output.pdf",PdfXfaType.Dynamic)
'close the document
document.Close()
Padding
Gets or sets the padding
Declaration
public PdfPaddings Padding { get; set; }
Property Value
Type |
---|
PdfPaddings |
Examples
//Create a new PDF XFA document.
PdfXfaDocument document = new PdfXfaDocument();
//Add a new XFA page.
PdfXfaPage xfaPage = document.Pages.Add();
//Create a new PDF XFA form
PdfXfaForm mainForm = new PdfXfaForm("subform1", xfaPage, xfaPage.GetClientSize().Width);
//Create a list box field and add the properties.
PdfXfaListBoxField listBoxField = new PdfXfaListBoxField("listBoxField", new SizeF(150, 50));
//Set padding.
listBoxField.Padding.All = 2;
//Set the caption text.
listBoxField.Caption.Text = "Known Languages";
listBoxField.Caption.Position = PdfXfaPosition.Top;
listBoxField.Caption.HorizontalAlignment = PdfXfaHorizontalAlignment.Center;
//Add the list box items
listBoxField.Items.Add("English");
listBoxField.Items.Add("French");
listBoxField.Items.Add("German");
//Add the field to the XFA form.
mainForm.Fields.Add(listBoxField);
//Add the XFA form to the document.
document.XfaForm = mainForm;
//Save the document.
document.Save("output.pdf", PdfXfaType.Dynamic);
//close the document
document.Close();
'Create a new PDF XFA document.
Dim document As New PdfXfaDocument()
'Add a new XFA page.
Dim xfaPage As PdfXfaPage = document.Pages.Add()
'Create a new PDF XFA form
Dim mainForm As New PdfXfaForm("subform1", xfaPage, xfaPage.GetClientSize().Width)
'Create a list box field and add the properties.
Dim listBoxField As New PdfXfaListBoxField("listBoxField", New SizeF(150, 50))
'Set padding.
listBoxField.Padding.All = 2
'Set the caption text.
listBoxField.Caption.Text = "Known Languages"
listBoxField.Caption.Position = PdfXfaPosition.Top
listBoxField.Caption.HorizontalAlignment = PdfXfaHorizontalAlignment.Center
'Add the list box items
listBoxField.Items.Add("English")
listBoxField.Items.Add("French")
listBoxField.Items.Add("German")
'Add the field to the XFA form.
mainForm.Fields.Add(listBoxField)
'Add the XFA form to the document.
document.XfaForm = mainForm
'Save the document.
document.Save("output.pdf",PdfXfaType.Dynamic)
'close the document
document.Close()
SelectedIndex
Gets or sets the selected index
Declaration
public int SelectedIndex { get; set; }
Property Value
Type |
---|
System.Int32 |
Examples
//Create a new PDF XFA document.
PdfXfaDocument document = new PdfXfaDocument();
//Add a new XFA page.
PdfXfaPage xfaPage = document.Pages.Add();
//Create a new PDF XFA form
PdfXfaForm mainForm = new PdfXfaForm("subform1", xfaPage, xfaPage.GetClientSize().Width);
//Create a list box field and add the properties.
PdfXfaListBoxField listBoxField = new PdfXfaListBoxField("listBoxField", new SizeF(150, 50));
//Set the caption text.
listBoxField.Caption.Text = "Known Languages";
listBoxField.Caption.Position = PdfXfaPosition.Top;
listBoxField.Caption.HorizontalAlignment = PdfXfaHorizontalAlignment.Center;
//Add the list box items
listBoxField.Items.Add("English");
listBoxField.Items.Add("French");
listBoxField.Items.Add("German");
//Set the selected index.
listBoxField.SelectedIndex = 1;
//Add the field to the XFA form.
mainForm.Fields.Add(listBoxField);
//Add the XFA form to the document.
document.XfaForm = mainForm;
//Save the document.
document.Save("output.pdf", PdfXfaType.Dynamic);
//close the document
document.Close();
'Create a new PDF XFA document.
Dim document As New PdfXfaDocument()
'Add a new XFA page.
Dim xfaPage As PdfXfaPage = document.Pages.Add()
'Create a new PDF XFA form
Dim mainForm As New PdfXfaForm("subform1", xfaPage, xfaPage.GetClientSize().Width)
'Create a list box field and add the properties.
Dim listBoxField As New PdfXfaListBoxField("listBoxField", New SizeF(150, 50))
'Set the caption text.
listBoxField.Caption.Text = "Known Languages"
listBoxField.Caption.Position = PdfXfaPosition.Top
listBoxField.Caption.HorizontalAlignment = PdfXfaHorizontalAlignment.Center
'Add the list box items
listBoxField.Items.Add("English")
listBoxField.Items.Add("French")
listBoxField.Items.Add("German")
'Set the selected index.
listBoxField.SelectedIndex = 1
'Add the field to the XFA form.
mainForm.Fields.Add(listBoxField)
'Add the XFA form to the document.
document.XfaForm = mainForm
'Save the document.
document.Save("output.pdf",PdfXfaType.Dynamic)
'close the document
document.Close()
SelectedValue
Gets or sets the selected value
Declaration
public string SelectedValue { get; set; }
Property Value
Type |
---|
System.String |
Examples
//Create a new PDF XFA document.
PdfXfaDocument document = new PdfXfaDocument();
//Add a new XFA page.
PdfXfaPage xfaPage = document.Pages.Add();
//Create a new PDF XFA form
PdfXfaForm mainForm = new PdfXfaForm("subform1", xfaPage, xfaPage.GetClientSize().Width);
//Create a list box field and add the properties.
PdfXfaListBoxField listBoxField = new PdfXfaListBoxField("listBoxField", new SizeF(150, 50));
//Set the caption text.
listBoxField.Caption.Text = "Known Languages";
listBoxField.Caption.Position = PdfXfaPosition.Top;
listBoxField.Caption.HorizontalAlignment = PdfXfaHorizontalAlignment.Center;
//Add the list box items
listBoxField.Items.Add("English");
listBoxField.Items.Add("French");
listBoxField.Items.Add("German");
//Set the selected value.
listBoxField.SelectedValue = "French";
//Add the field to the XFA form.
mainForm.Fields.Add(listBoxField);
//Add the XFA form to the document.
document.XfaForm = mainForm;
//Save the document.
document.Save("output.pdf", PdfXfaType.Dynamic);
//close the document
document.Close();
'Create a new PDF XFA document.
Dim document As New PdfXfaDocument()
'Add a new XFA page.
Dim xfaPage As PdfXfaPage = document.Pages.Add()
'Create a new PDF XFA form
Dim mainForm As New PdfXfaForm("subform1", xfaPage, xfaPage.GetClientSize().Width)
'Create a list box field and add the properties.
Dim listBoxField As New PdfXfaListBoxField("listBoxField", New SizeF(150, 50))
'Set the caption text.
listBoxField.Caption.Text = "Known Languages"
listBoxField.Caption.Position = PdfXfaPosition.Top
listBoxField.Caption.HorizontalAlignment = PdfXfaHorizontalAlignment.Center
'Add the list box items
listBoxField.Items.Add("English")
listBoxField.Items.Add("French")
listBoxField.Items.Add("German")
'Set the selected value.
listBoxField.SelectedValue = "French"
'Add the field to the XFA form.
mainForm.Fields.Add(listBoxField)
'Add the XFA form to the document.
document.XfaForm = mainForm
'Save the document.
document.Save("output.pdf",PdfXfaType.Dynamic)
'close the document
document.Close()
SelectionMode
Gets or sets selection mode of the list box field
Declaration
public PdfXfaSelectionMode SelectionMode { get; set; }
Property Value
Type |
---|
PdfXfaSelectionMode |
Examples
//Create a new PDF XFA document.
PdfXfaDocument document = new PdfXfaDocument();
//Add a new XFA page.
PdfXfaPage xfaPage = document.Pages.Add();
//Create a new PDF XFA form
PdfXfaForm mainForm = new PdfXfaForm("subform1", xfaPage, xfaPage.GetClientSize().Width);
//Create a list box field and add the properties.
PdfXfaListBoxField listBoxField = new PdfXfaListBoxField("listBoxField", new SizeF(150, 50));
//Set the caption text.
listBoxField.Caption.Text = "Known Languages";
listBoxField.Caption.Position = PdfXfaPosition.Top;
listBoxField.Caption.HorizontalAlignment = PdfXfaHorizontalAlignment.Center;
//Add the list box items
listBoxField.Items.Add("English");
listBoxField.Items.Add("French");
listBoxField.Items.Add("German");
//Set the selection mode.
listBoxField.SelectionMode = PdfXfaSelectionMode.Single;
//Add the field to the XFA form.
mainForm.Fields.Add(listBoxField);
//Add the XFA form to the document.
document.XfaForm = mainForm;
//Save the document.
document.Save("output.pdf", PdfXfaType.Dynamic);
//close the document
document.Close();
'Create a new PDF XFA document.
Dim document As New PdfXfaDocument()
'Add a new XFA page.
Dim xfaPage As PdfXfaPage = document.Pages.Add()
'Create a new PDF XFA form
Dim mainForm As New PdfXfaForm("subform1", xfaPage, xfaPage.GetClientSize().Width)
'Create a list box field and add the properties.
Dim listBoxField As New PdfXfaListBoxField("listBoxField", New SizeF(150, 50))
'Set the caption text.
listBoxField.Caption.Text = "Known Languages"
listBoxField.Caption.Position = PdfXfaPosition.Top
listBoxField.Caption.HorizontalAlignment = PdfXfaHorizontalAlignment.Center
'Add the list box items
listBoxField.Items.Add("English")
listBoxField.Items.Add("French")
listBoxField.Items.Add("German")
'Set the selection mode.
listBoxField.SelectionMode = PdfXfaSelectionMode.Single
'Add the field to the XFA form.
mainForm.Fields.Add(listBoxField)
'Add the XFA form to the document.
document.XfaForm = mainForm
'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.
Declaration
public object Clone()
Returns
Type | Description |
---|---|
System.Object | The copy of the new object for this instance. |
Examples
//Create a new PDF XFA document.
PdfXfaDocument document = new PdfXfaDocument();
//Add a new XFA page.
PdfXfaPage xfaPage = document.Pages.Add();
//Create a new PDF XFA form
PdfXfaForm mainForm = new PdfXfaForm("subform1", xfaPage, xfaPage.GetClientSize().Width);
//Create a list box field and add the properties.
PdfXfaListBoxField listBoxField = new PdfXfaListBoxField("listBoxField", new SizeF(150, 50));
//Set the caption text.
listBoxField.Caption.Text = "Known Languages";
listBoxField.Caption.Position = PdfXfaPosition.Top;
listBoxField.Caption.HorizontalAlignment = PdfXfaHorizontalAlignment.Center;
//Add the list box items
listBoxField.Items.Add("English");
listBoxField.Items.Add("French");
listBoxField.Items.Add("German");
//Add the field to the XFA form.
mainForm.Fields.Add(listBoxField);
//Clone the list box.
mainForm.Fields.Add(listBoxField.Clone() as PdfXfaListBoxField);
//Add the XFA form to the document.
document.XfaForm = mainForm;
//Save the document.
document.Save("output.pdf", PdfXfaType.Dynamic);
//close the document
document.Close();
'Create a new PDF XFA document.
Dim document As New PdfXfaDocument()
'Add a new XFA page.
Dim xfaPage As PdfXfaPage = document.Pages.Add()
'Create a new PDF XFA form
Dim mainForm As New PdfXfaForm("subform1", xfaPage, xfaPage.GetClientSize().Width)
'Create a list box field and add the properties.
Dim listBoxField As New PdfXfaListBoxField("listBoxField", New SizeF(150, 50))
'Set the caption text.
listBoxField.Caption.Text = "Known Languages"
listBoxField.Caption.Position = PdfXfaPosition.Top
listBoxField.Caption.HorizontalAlignment = PdfXfaHorizontalAlignment.Center
'Add the list box items
listBoxField.Items.Add("English")
listBoxField.Items.Add("French")
listBoxField.Items.Add("German")
'Add the field to the XFA form.
mainForm.Fields.Add(listBoxField)
'Clone the list box.
mainForm.Fields.Add(TryCase(listBoxField.Clone(), PdfXfaListBoxField))
'Add the XFA form to the document.
document.XfaForm = mainForm
'Save the document.
document.Save("output.pdf",PdfXfaType.Dynamic)
'close the document
document.Close()