Skip to main content
All docs
V26.1
  • ListBoxField Class

    A list box form field in a PDF document.

    Namespace: DevExpress.Docs.Pdf

    Assembly: DevExpress.Docs.Pdf.v26.1.dll

    Declaration

    public class ListBoxField :
        ChoiceField

    Remarks

    For more information, refer to the following help topic: DevExpress PDF Document API - Form Fields.

    Example

    How to: Add a List Box Field to a PDF Document

    The following code snippet adds a list box field with three options to a PDF document and binds it to a list box widget:

    DevExpress New PDF API library - List Box Field

    using DevExpress.Docs.Pdf;
    using DevExpress.Drawing.Printing;
    using System.Drawing;
    
    namespace ConsoleApp1;
    
    public class Program {
        public static async Task Main(string[] _) {
            using (PdfDocument pdfDocument = new()) {
                // Add an A4 page to the document.
                Page page = pdfDocument.Pages.Add(DXPaperKind.A4);
    
                // Create a list box field.
                ListBoxField listBoxField = new("listBox");
    
                // Add items to the list box field.
                listBoxField.Items.Add(new ChoiceFieldItem("Option #1"));
                listBoxField.Items.Add(new ChoiceFieldItem("Option #2"));
                listBoxField.Items.Add(new ChoiceFieldItem("Option #3"));
    
                // Add the list box field to the field collection.
                pdfDocument.Fields.Add(listBoxField);
    
                // Bind the list box field to a widget and set widget colors.
                ListBoxWidgetAnnotation listBoxWidget = new(listBoxField, bounds: new RectangleF(20, 620, 100, 30));
                listBoxWidget.BackgroundColor = PdfColor.White;
                listBoxWidget.OutlineColor = PdfColor.Red;
    
                page.Annotations.Add(listBoxWidget);
            }
        }
    }
    

    Implements

    Inheritance

    See Also