Skip to main content
A newer version of this page is available. .
.NET Framework 4.5.2+

PdfGraphicsAcroFormChoiceField.SelectValue(String) Method

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

Namespace: DevExpress.Pdf

Assembly: DevExpress.Pdf.v19.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);
        }
    }
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the SelectValue(String) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also