.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
.NET Core 3.0+

PdfGraphicsAcroFormComboBoxField Class

Represents a combo box field.

Namespace: DevExpress.Pdf

Assembly: DevExpress.Pdf.v19.2.Drawing.dll

Declaration

public class PdfGraphicsAcroFormComboBoxField :
    PdfGraphicsAcroFormChoiceField
Public Class PdfGraphicsAcroFormComboBoxField
    Inherits PdfGraphicsAcroFormChoiceField
public class PdfGraphicsAcroFormComboBoxField :
    PdfGraphicsAcroFormChoiceField
Public Class PdfGraphicsAcroFormComboBoxField
    Inherits PdfGraphicsAcroFormChoiceField
public class PdfGraphicsAcroFormComboBoxField :
    PdfGraphicsAcroFormChoiceField
Public Class PdfGraphicsAcroFormComboBoxField
    Inherits PdfGraphicsAcroFormChoiceField

Remarks

To create a combo box field, call the PdfGraphicsAcroFormField.CreateComboBox method with specified the field name and field rectangle.

To add values to a combo box, call one of the PdfGraphicsAcroFormChoiceField.AddValue overloaded methods.

You can specify the combo box name, tooltip and appearance using PdfGraphicsAcroFormField.Name, PdfGraphicsAcroFormField.ToolTip, PdfGraphicsAcroFormField.Appearance properties.

To select an item of a combo box by an export value, call the PdfAcroFormChoiceField.SelectValue method using this value.

To add a combo box field to PDF graphics, pass a PdfGraphicsAcroFormComboBoxField object representing the combo 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.

Examples

This example shows how to create a combo box field and add it to a PDF document using the Document Creation API.

using DevExpress.Pdf;
using System.Drawing;


namespace AddComboBoxField {
    class Program {
        static void Main(string[] args) {
            using (PdfDocumentProcessor processor = new PdfDocumentProcessor()) {

                // Create an empty document. 
                processor.CreateEmptyDocument("..\\..\\Result.pdf");

                // Create graphics and draw a combo box field.
                using (PdfGraphics graphics = processor.CreateGraphics()) {
                    DrawComboBoxField(graphics);

                    // Render a page with graphics.
                    processor.RenderNewPage(PdfPaperSize.Letter, graphics);
                }
            }
        }

        static void DrawComboBoxField(PdfGraphics graphics) {

            // Create a combo box field specifying its name and location.
            PdfGraphicsAcroFormComboBoxField comboBox = new PdfGraphicsAcroFormComboBoxField("combo Box", new RectangleF(20, 20, 100, 20));

            // Add values to the combo box.  
            comboBox.AddValue("Red");
            comboBox.AddValue("Yellow");
            comboBox.AddValue("Green");
            comboBox.AddValue("Blue");

            // Specify combo box selected value, text allignment, and appearance.
            comboBox.SelectValue("Red");
            comboBox.TextAlignment = PdfAcroFormStringAlignment.Far;
            comboBox.Appearance.BackgroundColor = Color.Beige;
            comboBox.Appearance.FontSize = 14;

            // Add the field to the document.
            graphics.AddFormField(comboBox);
        }
    }
}
See Also