Back to Devexpress

PdfAcroFormFacade.GetComboBoxFormField(String) Method

officefileapi-devexpress-dot-pdf-dot-pdfacroformfacade-dot-getcomboboxformfield-x28-system-dot-string-x29.md

latest4.7 KB
Original Source

PdfAcroFormFacade.GetComboBoxFormField(String) Method

Gets a specific combo box form field’s properties.

Namespace : DevExpress.Pdf

Assembly : DevExpress.Pdf.v25.2.Core.dll

NuGet Package : DevExpress.Pdf.Core

Declaration

csharp
public PdfComboBoxFormFieldFacade GetComboBoxFormField(
    string fullName
)
vb
Public Function GetComboBoxFormField(
    fullName As String
) As PdfComboBoxFormFieldFacade

Parameters

NameTypeDescription
fullNameString

A form field’s name.

|

Returns

TypeDescription
PdfComboBoxFormFieldFacade

An object that contains the form field’s properties.

|

Remarks

The PdfComboBoxFormFieldFacade object contains form field and widget properties without access to the form field’s inner structure. Use the Widgets property to get the form field widget settings.

The code sample below specifies the combo box value and disables multiple selection:

csharp
using (PdfDocumentProcessor pdfDocumentProcessor = new PdfDocumentProcessor())
{
    pdfDocumentProcessor.LoadDocument("Documents//FormDemo.pdf");

    PdfDocumentFacade documentFacade = pdfDocumentProcessor.DocumentFacade;
    PdfAcroFormFacade acroForm = documentFacade.AcroForm;

    //Set combo box field value:
    PdfComboBoxFormFieldFacade nationalityField = acroForm.GetComboBoxFormField("Nationality");
    nationalityField.Value = nationalityField.Items[68].Value;

    //Disable user input:
    nationalityField.Editable = false;

    //Disable multiple selection:
    nationalityField.MultiSelect = false;

    //Sort list items alphabetically:
    nationalityField.Sorted = true;
    pdfDocumentProcessor.SaveDocument("FormDemo_new.pdf");
}
vb
Using pdfDocumentProcessor As New PdfDocumentProcessor()
  pdfDocumentProcessor.LoadDocument("Documents//FormDemo.pdf")

  Dim documentFacade As PdfDocumentFacade = pdfDocumentProcessor.DocumentFacade
  Dim acroForm As PdfAcroFormFacade = documentFacade.AcroForm

  'Set combo box field value:
  Dim nationalityField As PdfComboBoxFormFieldFacade = acroForm.GetComboBoxFormField("Nationality")
  nationalityField.Value = nationalityField.Items(68).Value

  'Disable user input:
  nationalityField.Editable = False

  'Disable multiple selection:
  nationalityField.MultiSelect = False

  'Sort list items alphabetically:
  nationalityField.Sorted = True
  pdfDocumentProcessor.SaveDocument("FormDemo_new.pdf")
End Using

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the GetComboBoxFormField(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-fill-interactive-form-fields/CS/PdfFormFilling/PdfFormFilling.cs#L68

csharp
PdfComboBoxFormFieldFacade countryField = acroForm.GetComboBoxFormField("Address.Country");
countryField.Value = countryField.Items[0].Value;

pdf-document-api-fill-interactive-form-fields/VB/PdfFormFilling/PdfFormFilling.vb#L62

vb
Dim countryField As PdfComboBoxFormFieldFacade = acroForm.GetComboBoxFormField("Address.Country")
countryField.Value = countryField.Items(0).Value

See Also

PdfAcroFormFacade Class

PdfAcroFormFacade Members

DevExpress.Pdf Namespace