.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

PdfGraphicsAcroFormChoiceField.SelectValue(String) Method

Selects an item of a combo box and list box by their export value.

Namespace: DevExpress.Pdf

Assembly: DevExpress.Pdf.v21.1.Drawing.dll

Declaration

public bool SelectValue(
    string exportValue
)

Parameters

Name Type Description
exportValue String

A String value that represents the item’s export value.

Returns

Type Description
Boolean

true, if the combo box or list box item was successfully selected; otherwise, false.

Example

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