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

    Contains properties used to customize the list box field’s widget annotation.

    Namespace: DevExpress.Docs.Pdf

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

    NuGet Package: DevExpress.Docs.Pdf

    Declaration

    public class ListBoxWidgetAnnotation :
        WidgetAnnotation

    Remarks

    A widget annotation contains a form field’s appearance and display properties. One field can be related to multiple widget annotations.

    Use properties of the WidgetAnnotation base class to specify the form field widget settings.

    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