PdfGraphicsAcroFormListBoxField Class
Represents a list box field.
Namespace: DevExpress.Pdf
Assembly: DevExpress.Pdf.v19.1.Drawing.dll
Declaration
Remarks
To create a list box field, call the PdfGraphicsAcroFormField.CreateListBox method with the specified the field name and field rectangle.
To add values to the list box, call one of the PdfGraphicsAcroFormChoiceField.AddValue overloaded methods.
You can also specify the list box field properties, for example, list box name, tooltip and appearance using PdfGraphicsAcroFormField.Name, PdfGraphicsAcroFormField.ToolTip, PdfGraphicsAcroFormField.Appearance properties.
To select an item of a list box by its export value, call the PdfGraphicsAcroFormChoiceField.SelectValue method using this value.
To add a list box field to PDF graphics, pass a PdfGraphicsAcroFormListBoxField object representing the list box field as a parameter to the PdfGraphics.AddFormField method. To access PdfGraphics, you need to reference the DevExpress.Pdf.Drawing assembly.
To render a page with the PDF graphics, call one of PdfDocumentProcessor.RenderNewPage overloaded methods.
Example
This example shows how to create a list box field and add it to a PDF document using the Document Creation API.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-add-a-list-box-field-to-a-document-t494219
Imports DevExpress.Pdf
Imports System.Drawing
Namespace AddListBoxField
Friend Class Program
Shared Sub Main(ByVal args() As String)
Using processor As New PdfDocumentProcessor()
' Create an empty document.
processor.CreateEmptyDocument("..\..\Result.pdf")
' Create graphics and draw a list box field.
Using graphics As PdfGraphics = processor.CreateGraphics()
DrawListBoxField(graphics)
' Render a page with graphics.
processor.RenderNewPage(PdfPaperSize.Letter, graphics)
End Using
End Using
End Sub
Private Shared Sub DrawListBoxField(ByVal graphics As PdfGraphics)
' Create a list box field specifying its name and location.
Dim listBox As New PdfGraphicsAcroFormListBoxField("list box", New RectangleF(20, 20, 100, 120))
' Add values to the list box.
listBox.AddValue("Blue")
listBox.AddValue("Green")
listBox.AddValue("Red")
listBox.AddValue("Yellow")
' Specify list box appearance, text alignment, and select value.
listBox.Appearance.BackgroundColor = Color.Aqua
listBox.TextAlignment = PdfAcroFormStringAlignment.Far
listBox.SelectValue("Blue")
' Add the field to the document.
graphics.AddFormField(listBox)
End Sub
End Class
End Namespace