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

    A combo box form field that allows users to select an option from a drop-down list in a PDF document.

    Namespace: DevExpress.Docs.Pdf

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

    Declaration

    public class ComboBoxField :
        ChoiceField

    Remarks

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

    Example

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

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

    DevExpress New PDF API library - Combo 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 combo box field.
                ComboBoxField comboBoxField = new("comboBox");
    
                // Add items to the combo box field.
                comboBoxField.Items.Add(new ChoiceFieldItem("Option #1"));
                comboBoxField.Items.Add(new ChoiceFieldItem("Option #2"));
                comboBoxField.Items.Add(new ChoiceFieldItem("Option #3"));
    
                // Add the combo box field to the field collection.
                pdfDocument.Fields.Add(comboBoxField);
    
                // Set the default selected value.
                comboBoxField.Value = "Option #2";
    
                // Bind the combo box field to a widget and place it on the page.
                ComboBoxWidgetAnnotation comboBoxWidget = new(comboBoxField, bounds: new RectangleF(20, 700, 100, 30));
                page.Annotations.Add(comboBoxWidget);
            }
        }
    }
    

    Implements

    Inheritance

    See Also