officefileapi-devexpress-dot-pdf-dot-pdfgraphicsacroformchoicefield-dot-selectvalue-x28-system-dot-string-x29.md
Selects an item in a combo box or a list box by its export value.
Namespace : DevExpress.Pdf
Assembly : DevExpress.Pdf.v25.2.Drawing.dll
NuGet Package : DevExpress.Pdf.Drawing
public bool SelectValue(
string exportValue
)
Public Function SelectValue(
exportValue As String
) As Boolean
| Name | Type | Description |
|---|---|---|
| exportValue | String |
The item’s export value.
|
| Type | Description |
|---|---|
| Boolean |
true , if the combo box or list box item was successfully selected; otherwise, false.
|
This example uses PDF Graphics API to create a combo box field and add it to a PDF page.
using DevExpress.Pdf;
using System.Drawing;
//...
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.CreateGraphicsPageSystem())
{
DrawComboBoxField(graphics);
// Render a page with graphics.
processor.RenderNewPage(PdfPaperSize.Letter, graphics);
}
}
}
static void DrawComboBoxField(PdfGraphics graphics)
{
// Create a combo box field
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 alignment, 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);
}
Imports DevExpress.Pdf
Imports System.Drawing
'...
Shared Sub Main(ByVal args() As String)
Using processor As New PdfDocumentProcessor()
' Create an empty document.
processor.CreateEmptyDocument("..\..\Result.pdf")
' Create graphics and draw a combo box field.
Using graphics As PdfGraphics = processor.CreateGraphicsPageSystem()
DrawComboBoxField(graphics)
' Render a page with graphics.
processor.RenderNewPage(PdfPaperSize.Letter, graphics)
End Using
End Using
End Sub
Private Shared Sub DrawComboBoxField(ByVal graphics As PdfGraphics)
' Create a combo box field
Dim comboBox As 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 alignment, 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)
End Sub
The following code snippet (auto-collected from DevExpress Examples) contains a reference 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.
pdf-document-api-create-combo-box-field/CS/AddComboBoxField/Program.cs#L37
// Specify combo box selected value, text allignment, and appearance.
comboBox.SelectValue("Red");
comboBox.TextAlignment = PdfAcroFormStringAlignment.Far;
pdf-document-api-create-combo-box-field/VB/AddComboBoxField/Program.vb#L33
' Specify combo box selected value, text allignment, and appearance.
comboBox.SelectValue("Red")
comboBox.TextAlignment = PdfAcroFormStringAlignment.Far
See Also
PdfGraphicsAcroFormChoiceField Class