Back to Devexpress

How to: Obtain a Checked Appearance Name for Each Radio Button in the Radio Group

officefileapi-120190-pdf-document-api-examples-interactive-form-how-to-obtain-a-checked-appearance-name-for-each-radio-button-in-the-radio-group.md

latest2.0 KB
Original Source

How to: Obtain a Checked Appearance Name for Each Radio Button in the Radio Group

  • Sep 22, 2025

This code snippet gets a checked appearance name for each radio button and check the corresponding radio button with the obtained value.

View Example

csharp
using DevExpress.Pdf;

static void Main(string[] args)
{
    // Load a document with an interactive form.
    PdfDocumentProcessor processor = new PdfDocumentProcessor();
    processor.LoadDocument(@"DocumentToFill.pdf");

    // Retrieve the form field facade:
    PdfDocumentFacade documentFacade = processor.DocumentFacade;
    PdfAcroFormFacade acroFormFacade = documentFacade.AcroForm;

    // Specify a checked appearance name for the Female radio button:
    PdfRadioGroupFormFieldFacade genderField = acroFormFacade.GetRadioGroupFormField("Gender");
    foreach (PdfFormFieldItem item in genderField.Field.Items)
    {
        if (item.Value == "Female")
            genderField.Value = item.Value;
    }

    // Save the modified document.
    processor.SaveDocument("..\\..\\Result.pdf");
}
vb
Imports DevExpress.Pdf

Shared Sub Main(ByVal args() As String)
    ' Load a document with an interactive form.
    Dim processor As New PdfDocumentProcessor()
    processor.LoadDocument("DocumentToFill.pdf")

    ' Retrieve the form field facade:
    Dim documentFacade As PdfDocumentFacade = processor.DocumentFacade
    Dim acroFormFacade As PdfAcroFormFacade = documentFacade.AcroForm

    ' Specify a checked appearance name for the Female radio button:
    Dim genderField As PdfRadioGroupFormFieldFacade = acroFormFacade.GetRadioGroupFormField("Gender")
    For Each item As PdfFormFieldItem In genderField.Field.Items
        If item.Value = "Female" Then
            genderField.Value = item.Value
        End If
    Next item

    ' Save the modified document.
    processor.SaveDocument("..\..\Result.pdf")
End Sub